Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing test run script should not fail np when using Yarn #275

Closed
sindresorhus opened this issue Jun 4, 2018 · 10 comments
Closed

Missing test run script should not fail np when using Yarn #275

sindresorhus opened this issue Jun 4, 2018 · 10 comments
Labels
bug 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted

Comments

@sindresorhus
Copy link
Owner

sindresorhus commented Jun 4, 2018

Issuehunt badges

When using npm it just exists with code 0 when the test script is missing, but when using Yarn it exists with code 1. I've partially fixed it in acbaece, it passes the step, but it still shows an error message after exiting.

 ✔ Prerequisite check
 ✔ Git
 ✔ Running tests using Yarn
 ↓ Bumping version using Yarn [skipped]
   → Public package: version will be bumped using yarn publish.
 ✔ Publishing package using Yarn
 ✔ Pushing tags

 sindre-playground 0.23.12 published 🎉
Error: Command failed: yarn test


    at makeError (/Users/sindresorhus/dev/oss/np/node_modules/execa/index.js:172:9)
    at Promise.all.then.arr (/Users/sindresorhus/dev/oss/np/node_modules/execa/index.js:277:16)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
Error: Command failed: yarn test


    at makeError (/Users/sindresorhus/dev/oss/np/node_modules/execa/index.js:172:9)
    at Promise.all.then.arr (/Users/sindresorhus/dev/oss/np/node_modules/execa/index.js:277:16)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

dflupu earned $80.00 by resolving this issue!

@07Gond

This comment has been minimized.

@sindresorhus
Copy link
Owner Author

I have a feeling this is caused by

np/index.js

Lines 17 to 25 in cec8e00

const exec = (cmd, args) => {
// Use `Observable` support if merged https://github.com/sindresorhus/execa/pull/26
const cp = execa(cmd, args);
return merge(
streamToObservable(cp.stdout.pipe(split()), {await: cp}),
streamToObservable(cp.stderr.pipe(split()), {await: cp})
).pipe(filter(Boolean));
};
or rather stream-to-observable, but I haven't looked closely into it.

@IssueHuntBot
Copy link

@issuehuntfest has funded $80.00 to this issue. See it on IssueHunt

@Norris1z
Copy link

@sindresorhus running echo $? after yarn test with no test run script returns 1 whereas it returns 0 for npm. Don't you think this is caused by yarn itself?

@sindresorhus
Copy link
Owner Author

@Norris1z Yup, but another part of the problem that needs to be fixed is that it only shows the error on exit, and doesn't affect the np exit code, instead of throwing it right away, so something about the error handling and Observables are wrong.

@Norris1z
Copy link

@sindresorhus you're right. It is a problem with the Observables.

title: "Running tests using Yarn",
enabled: () => opts.yarn === true,
task: () =>
  execa.stdout("yarn", ["test"]).catch(error => {
    if (!error.message.includes('Command "test" not found')) {
        throw new Error(error);
   }
})

This method works great. Should i submit a pr for this or we should still debug the Observables?

@sindresorhus
Copy link
Owner Author

@Norris1z We need to use Observables so the child process output is streamed into the task output. With your change the test output will only be shown when it's done.

we should still debug the Observables?

Yes

@Norris1z
Copy link

@sindresorhus i found out that somehow after the failed yarn test command, two empty commands are sent to execa which produces { code: 1, signal: null, stdout: '', stderr: '' } and because both stdout and stderr are empty it slips through the observables somehow. I posted an issue on the execa repo to clarify if { code: 1, signal: null, stdout: '', stderr: '' } was a valid or if we could perform an extra check on execa to catch errors with both stdout and stderr empty.

@IssueHuntBot
Copy link

@dflupu has submitted a pull request. See it on IssueHunt

@IssueHuntBot
Copy link

@sindresorhus has rewarded $72.00 to @dflupu. See it on IssueHunt

  • 💰 Total deposit: $80.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $8.00

@issuehunt-oss issuehunt-oss bot added the 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt label May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted
Projects
None yet
Development

No branches or pull requests

4 participants