Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.4k
cli: ensure --run has proper pwd#53600
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
Closed
Uh oh!
There was an error while loading. Please reload this page.
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0921a18
cli: ensure --run has proper pwd
bmeck fb4faed
nit
bmeck c0d33ee
doc
bmeck 1726d9f
Update test/fixtures/run-script/package.json
bmeck d167213
Update test/fixtures/run-script/package.json
bmeck 6f43ae7
Apply suggestions from code review
bmeck 250523d
review nits
bmeck 7cb49aa
nits
bmeck 6b0d81b
Update src/node_task_runner.cc
bmeck 6ab8d56
remove duplicate test
bmeck 3db4c32
fixup
bmeck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "scripts": {}, | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "scripts": { | ||
| "array": [], | ||
| "boolean": true, | ||
| "null": null, | ||
| "number": 1.0, | ||
| "object": {} | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {} |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| 'use strict'; | ||
| const common = require('../common'); | ||
| common.requireNoPackageJSONAbove(); | ||
| const { it, describe } = require('node:test'); | ||
| const assert = require('node:assert'); | ||
| @@ -15,7 +17,6 @@ describe('node --run [command]', () => { | ||
| { cwd: __dirname }, | ||
| ); | ||
| assert.match(child.stderr, /ExperimentalWarning: Task runner is an experimental feature and might change at any time/); | ||
| assert.match(child.stderr, /Can't read package\.json/); | ||
| assert.strictEqual(child.stdout, ''); | ||
| assert.strictEqual(child.code, 1); | ||
| }); | ||
| @@ -26,7 +27,9 @@ describe('node --run [command]', () => { | ||
| [ '--no-warnings', '--run', 'test'], | ||
| { cwd: __dirname }, | ||
| ); | ||
| assert.match(child.stderr, /Can't read package\.json/); | ||
| assert.match(child.stderr, /Can't find package\.json[\s\S]*/); | ||
| // Ensure we show the path that starting path for the search | ||
| assert(child.stderr.includes(__dirname)); | ||
| assert.strictEqual(child.stdout, ''); | ||
| assert.strictEqual(child.code, 1); | ||
| }); | ||
| @@ -53,6 +56,101 @@ describe('node --run [command]', () => { | ||
| assert.strictEqual(child.code, 0); | ||
| }); | ||
| it.only('chdirs into package directory', async () => { | ||
| const child = await common.spawnPromisified( | ||
| process.execPath, | ||
| [ '--no-warnings', '--run', `pwd${envSuffix}`], | ||
| { cwd: fixtures.path('run-script/sub-directory') }, | ||
| ); | ||
| assert.strictEqual(child.stdout.trim(), fixtures.path('run-script')); | ||
| assert.strictEqual(child.stderr, ''); | ||
| assert.strictEqual(child.code, 0); | ||
| }); | ||
| it('includes actionable info when possible', async () => { | ||
| { | ||
| const child = await common.spawnPromisified( | ||
| process.execPath, | ||
| [ '--no-warnings', '--run', 'missing'], | ||
bmeck marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| { cwd: fixtures.path('run-script') }, | ||
| ); | ||
| assert.strictEqual(child.stdout, ''); | ||
| assert(child.stderr.includes(fixtures.path('run-script/package.json'))); | ||
| assert(child.stderr.includes('no test specified')); | ||
| assert.strictEqual(child.code, 1); | ||
| } | ||
| { | ||
| const child = await common.spawnPromisified( | ||
| process.execPath, | ||
| [ '--no-warnings', '--run', 'test'], | ||
| { cwd: fixtures.path('run-script/missing-scripts') }, | ||
| ); | ||
| assert.strictEqual(child.stdout, ''); | ||
| assert(child.stderr.includes(fixtures.path('run-script/missing-scripts/package.json'))); | ||
| assert.strictEqual(child.code, 1); | ||
| } | ||
| { | ||
| const child = await common.spawnPromisified( | ||
| process.execPath, | ||
| [ '--no-warnings', '--run', 'test'], | ||
| { cwd: fixtures.path('run-script/invalid-json') }, | ||
| ); | ||
| assert.strictEqual(child.stdout, ''); | ||
| assert(child.stderr.includes(fixtures.path('run-script/invalid-json/package.json'))); | ||
| assert.strictEqual(child.code, 1); | ||
| } | ||
| { | ||
| const child = await common.spawnPromisified( | ||
| process.execPath, | ||
| [ '--no-warnings', '--run', 'array'], | ||
| { cwd: fixtures.path('run-script/invalid-schema') }, | ||
| ); | ||
| assert.strictEqual(child.stdout, ''); | ||
| assert(child.stderr.includes(fixtures.path('run-script/invalid-schema/package.json'))); | ||
| assert.strictEqual(child.code, 1); | ||
| } | ||
| { | ||
| const child = await common.spawnPromisified( | ||
| process.execPath, | ||
| [ '--no-warnings', '--run', 'boolean'], | ||
| { cwd: fixtures.path('run-script/invalid-schema') }, | ||
| ); | ||
| assert.strictEqual(child.stdout, ''); | ||
| assert(child.stderr.includes(fixtures.path('run-script/invalid-schema/package.json'))); | ||
| assert.strictEqual(child.code, 1); | ||
| } | ||
| { | ||
| const child = await common.spawnPromisified( | ||
| process.execPath, | ||
| [ '--no-warnings', '--run', 'null'], | ||
| { cwd: fixtures.path('run-script/invalid-schema') }, | ||
| ); | ||
| assert.strictEqual(child.stdout, ''); | ||
| assert(child.stderr.includes(fixtures.path('run-script/invalid-schema/package.json'))); | ||
| assert.strictEqual(child.code, 1); | ||
| } | ||
| { | ||
| const child = await common.spawnPromisified( | ||
| process.execPath, | ||
| [ '--no-warnings', '--run', 'number'], | ||
| { cwd: fixtures.path('run-script/invalid-schema') }, | ||
| ); | ||
| assert.strictEqual(child.stdout, ''); | ||
| assert(child.stderr.includes(fixtures.path('run-script/invalid-schema/package.json'))); | ||
| assert.strictEqual(child.code, 1); | ||
| } | ||
| { | ||
| const child = await common.spawnPromisified( | ||
| process.execPath, | ||
| [ '--no-warnings', '--run', 'object'], | ||
| { cwd: fixtures.path('run-script/invalid-schema') }, | ||
| ); | ||
| assert.strictEqual(child.stdout, ''); | ||
| assert(child.stderr.includes(fixtures.path('run-script/invalid-schema/package.json'))); | ||
| assert.strictEqual(child.code, 1); | ||
| } | ||
| }); | ||
| it('appends positional arguments', async () => { | ||
| const child = await common.spawnPromisified( | ||
| process.execPath, | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.