-
Notifications
You must be signed in to change notification settings - Fork 66
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome approach! Perhaps add a test?
@@ -66,7 +68,7 @@ const runCommand = (command, args, options) => { | |||
if (code !== 0) { | |||
reject(new Error(stderr)); | |||
} | |||
resolve(stdout); | |||
resolve({ stdout, stderr }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you've checked we're not expecting this to resolve with only stdout
anywhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was supposed to. Thanks for the reminder! Fixed in a218ba4.
if (global.argOpts.debug) { | ||
console.log(colors.green(stdout)); | ||
process.stdout.write(colors.green(str)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change from console.log
to process.stdout
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log
appends a newline on every call, but the stdout from the external command already has newlines. We don't want to print a newline every time we get a piece of text from stdout.
@FokkeZB thanks for reviewing. I wouldn't worry about adding a test for now though. To test it, we need to test the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure the fs.exists
needs to change. I like the stderr/stdout change.
To take it a step further (out of scope for this PR), we could move this to shelljs, which will handle windows compatibility and simplify this code greatly (I'm all for using other people's tested code over rolling our own).
src/utils/build.js
Outdated
'node_modules', | ||
constants.PLATFORM_PACKAGE | ||
); | ||
if (!fs.exists(corePath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fs.exists
is both asynchronous and deprecated (docs). I believe this needs to be fs.existsSync
or one of the other methods mentioned in that doc link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Fixed in 5fb57c1.
Fixes #82 and zapier/zapier#16579.
Our current code in
zapier build
assumes ifnpm install
returns 0, everything is good. Butnpm install
may fail without returning a non-zero exit code. For example, trynpm install
when thename
inpackage.json
has a space character. In this case,npm
prints the error to stderr, but exits with 0 as if it was successful.So what we should do instead, is to check further if
APP_DIR/node_modules/zapier-platform-core
exists to make surenpm install
is really successful before moving on to the next step.With this PR, now if you
zapier build
an app with a space in thiername
inpackage.json
, we'll show the stderr fromnpm
: