Created
March 28, 2018 12:06
-
-
Save m-abs/7143d2b598091c577a57f6d0fe8948c8 to your computer and use it in GitHub Desktop.
patch nrwl/nx formatter for nativescript projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
realpath() { | |
[[ $1 = /* ]] && echo "$1" || (cd "$PWD/${1#./}" && echo $PWD); | |
} | |
apply_patch() { | |
PATCH=$1 | |
patch -p0 -N --dry-run --silent -i $PATCH 2>&1 > /dev/null | |
if [[ $? -eq 0 ]]; then | |
patch -p0 -N --silent -i $PATCH | |
if [[ $? -eq 0 ]]; then | |
echo "APPLIED PATCH: ${PATCH}"; | |
else | |
echo "COULDN'T APPLY THE PATCH: ${PATCH}"; | |
exit 127 | |
fi | |
else | |
patch -p0 -N -R --dry-run --silent -i $PATCH 2>&1 > /dev/null | |
if [[ $? -eq 0 ]]; then | |
echo "ALREADY APPLIED: ${PATCH}"; | |
else | |
echo "CANNOT APPLY THE PATCH: ${PATCH}"; | |
exit 127 | |
fi | |
fi | |
} | |
PATCH_DIR=$(realpath $(dirname $0)); | |
ROOT=$(git rev-parse --show-toplevel); | |
echo -e "Applying local patches from ${PATCH_DIR}\n"; | |
cd $ROOT | |
for patch in $PATCH_DIR/*.patch; do | |
apply_patch $patch | |
done | |
echo -e "\nDONE - Applying local patches from ${PATCH_DIR}"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- node_modules/@nrwl/schematics/src/command-line/format.js.orig 2018-03-28 13:15:08.107680784 +0200 | |
+++ node_modules/@nrwl/schematics/src/command-line/format.js 2018-03-28 13:15:22.124751217 +0200 | |
@@ -33,7 +33,7 @@ function getPatterns(args) { | |
return libsAndApp ? getPatternsFromApps(patterns) : patterns; | |
} | |
catch (e) { | |
- return ['"{apps,libs}/**/*.ts"']; | |
+ return ['"{apps,libs}/**/*.ts"', "!apps/**/platforms/{android,ios}/**/*.ts"]; | |
} | |
} | |
function getPatternsFromApps(affectedFiles) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When you generate lib/modules/etc in an nx+nativescript project, the
nx format
will crawl through all the*.ts
-files in the platform folder.This is a quick and very dirty fix to get around that.
apply-patches.sh
is a shell script for applying patches tonode_modules
(which is very dirty -- but sometimes needed).fix-nw-format-for-tns.patch
is the patch itself, which tells the formatter to ignore the files under theplatforms
-folderPut both files into the
<gitroot>/patches
-folder and markapply-patches.sh
as executable.Edit
package.json
and changepostinstall
fromTo:
./patches/apply-patches.sh; ./node_modules/.bin/nx postinstall
Run
npm install
again or callpatches/apply-patches.sh
directly to apply the patchIssue with
template-nativescript-nx
: NathanWalker/template-nativescript-nx#12