Skip to content

Commit

Permalink
src: mark node --run as stable
Browse files Browse the repository at this point in the history
PR-URL: #53763
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Ruy Adorno <ruy@vlt.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
anonrig authored and targos committed Oct 4, 2024
1 parent 22e601a commit 465d050
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 37 deletions.
2 changes: 1 addition & 1 deletion doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -2097,7 +2097,7 @@ changes:
`PATH` environment variable accordingly.
-->

> Stability: 1.2 - Release candidate
> Stability: 2 - Stable
This runs a specified command from a package.json's `"scripts"` object.
If a missing `"command"` is provided, it will list the available scripts.
Expand Down
8 changes: 0 additions & 8 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1070,14 +1070,6 @@ InitializeOncePerProcessInternal(const std::vector<std::string>& args,
}

if (!per_process::cli_options->run.empty()) {
// TODO(@anonrig): Handle NODE_NO_WARNINGS, NODE_REDIRECT_WARNINGS,
// --disable-warning and --redirect-warnings.
if (per_process::cli_options->per_isolate->per_env->warnings) {
fprintf(stderr,
"ExperimentalWarning: Task runner is an experimental feature and "
"might change at any time\n\n");
}

auto positional_args = task_runner::GetPositionalArgs(args);
result->early_return_ = true;
task_runner::RunTask(
Expand Down
45 changes: 17 additions & 28 deletions test/parallel/test-node-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,10 @@ const fixtures = require('../common/fixtures');
const envSuffix = common.isWindows ? '-windows' : '';

describe('node --run [command]', () => {
it('should emit experimental warning', async () => {
const child = await common.spawnPromisified(
process.execPath,
[ '--run', 'test'],
{ cwd: __dirname },
);
assert.match(child.stderr, /ExperimentalWarning: Task runner is an experimental feature and might change at any time/);
assert.strictEqual(child.stdout, '');
assert.strictEqual(child.code, 1);
});

it('returns error on non-existent file', async () => {
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', 'test'],
[ '--run', 'test'],
{ cwd: __dirname },
);
assert.match(child.stderr, /Can't find package\.json[\s\S]*/);
Expand All @@ -48,7 +37,7 @@ describe('node --run [command]', () => {
it('adds node_modules/.bin to path', async () => {
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', `ada${envSuffix}`],
[ '--run', `ada${envSuffix}`],
{ cwd: fixtures.path('run-script') },
);
assert.match(child.stdout, /06062023/);
Expand All @@ -59,7 +48,7 @@ describe('node --run [command]', () => {
it('chdirs into package directory', async () => {
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', `pwd${envSuffix}`],
[ '--run', `pwd${envSuffix}`],
{ cwd: fixtures.path('run-script/sub-directory') },
);
assert.strictEqual(child.stdout.trim(), fixtures.path('run-script'));
Expand All @@ -71,7 +60,7 @@ describe('node --run [command]', () => {
{
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', 'missing'],
[ '--run', 'missing'],
{ cwd: fixtures.path('run-script') },
);
assert.strictEqual(child.stdout, '');
Expand All @@ -82,7 +71,7 @@ describe('node --run [command]', () => {
{
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', 'test'],
[ '--run', 'test'],
{ cwd: fixtures.path('run-script/missing-scripts') },
);
assert.strictEqual(child.stdout, '');
Expand All @@ -92,7 +81,7 @@ describe('node --run [command]', () => {
{
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', 'test'],
[ '--run', 'test'],
{ cwd: fixtures.path('run-script/invalid-json') },
);
assert.strictEqual(child.stdout, '');
Expand All @@ -102,7 +91,7 @@ describe('node --run [command]', () => {
{
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', 'array'],
[ '--run', 'array'],
{ cwd: fixtures.path('run-script/invalid-schema') },
);
assert.strictEqual(child.stdout, '');
Expand All @@ -112,7 +101,7 @@ describe('node --run [command]', () => {
{
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', 'boolean'],
[ '--run', 'boolean'],
{ cwd: fixtures.path('run-script/invalid-schema') },
);
assert.strictEqual(child.stdout, '');
Expand All @@ -122,7 +111,7 @@ describe('node --run [command]', () => {
{
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', 'null'],
[ '--run', 'null'],
{ cwd: fixtures.path('run-script/invalid-schema') },
);
assert.strictEqual(child.stdout, '');
Expand All @@ -132,7 +121,7 @@ describe('node --run [command]', () => {
{
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', 'number'],
[ '--run', 'number'],
{ cwd: fixtures.path('run-script/invalid-schema') },
);
assert.strictEqual(child.stdout, '');
Expand All @@ -142,7 +131,7 @@ describe('node --run [command]', () => {
{
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', 'object'],
[ '--run', 'object'],
{ cwd: fixtures.path('run-script/invalid-schema') },
);
assert.strictEqual(child.stdout, '');
Expand All @@ -154,7 +143,7 @@ describe('node --run [command]', () => {
it('appends positional arguments', async () => {
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', `positional-args${envSuffix}`, '--', '--help "hello world test"', 'A', 'B', 'C'],
[ '--run', `positional-args${envSuffix}`, '--', '--help "hello world test"', 'A', 'B', 'C'],
{ cwd: fixtures.path('run-script') },
);
if (common.isWindows) {
Expand All @@ -170,7 +159,7 @@ describe('node --run [command]', () => {
it('should set PATH environment variable with paths appended with node_modules/.bin', async () => {
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', `path-env${envSuffix}`],
[ '--run', `path-env${envSuffix}`],
{ cwd: fixtures.path('run-script/sub-directory') },
);
assert.ok(child.stdout.includes(fixtures.path('run-script/node_modules/.bin')));
Expand All @@ -191,7 +180,7 @@ describe('node --run [command]', () => {
const packageJsonPath = fixtures.path('run-script/package.json');
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', scriptName],
[ '--run', scriptName],
{ cwd: fixtures.path('run-script') },
);
assert.ok(child.stdout.includes(scriptName));
Expand All @@ -204,7 +193,7 @@ describe('node --run [command]', () => {
const packageJsonPath = fixtures.path('run-script/package.json');
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', `special-env-variables${envSuffix}`],
[ '--run', `special-env-variables${envSuffix}`],
{ cwd: fixtures.path('run-script/sub-directory') },
);
assert.ok(child.stdout.includes(packageJsonPath));
Expand All @@ -215,7 +204,7 @@ describe('node --run [command]', () => {
it('returns error on unparsable file', async () => {
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', 'test'],
[ '--run', 'test'],
{ cwd: fixtures.path('run-script/cannot-parse') },
);
assert.match(child.stderr, /Can't parse/);
Expand All @@ -226,7 +215,7 @@ describe('node --run [command]', () => {
it('returns error when there is no "scripts" field file', async () => {
const child = await common.spawnPromisified(
process.execPath,
[ '--no-warnings', '--run', 'test'],
[ '--run', 'test'],
{ cwd: fixtures.path('run-script/cannot-find-script') },
);
assert.match(child.stderr, /Can't find "scripts" field in/);
Expand Down

0 comments on commit 465d050

Please sign in to comment.