Skip to content

Commit

Permalink
fix: run the command from inside node_modules
Browse files Browse the repository at this point in the history
Allow d2-style to first scan its own node_modules[0] for the deps it
needs, and if the deps are missing, e.g. if Yarn has hoisted shared deps
higher up the tree[1], then d2-style can use the standard node module
resolution behavior to "find-up" its parents node_modules.

Also use find-up to find the nearest .bin folder that has d2-style, and
use cross-spawn to run the tools instead of npx for consistency.

[0] ./node_modules/@dhis2/cli-style/node_modules/{dep}
[1] ./node_modules/{dep}
  • Loading branch information
varl committed Apr 29, 2020
1 parent 03a8a5b commit fd620c5
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/files.js
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ function selectFiles(files, pattern, staged) {
globstar: true,
dot: true,
ignore: blacklist.map(b => `**/${b}/**`),
absolute: false,
absolute: true,
})

if (files) {
1 change: 1 addition & 0 deletions src/utils/run.js
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ exports.bin = (cmd, { args, opts }, callback) => {
return handleRun(
spawn.sync(binCmd, args, {
stdio: 'inherit',
cwd: PACKAGE_ROOT,
...opts,
}),
callback

0 comments on commit fd620c5

Please sign in to comment.