xref: /third_party/node/test/parallel/test-cli-syntax-eval.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst { exec } = require('child_process');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst node = process.execPath;
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci// Should throw if -c and -e flags are both passed
101cb0ef41Sopenharmony_ci['-c', '--check'].forEach(function(checkFlag) {
111cb0ef41Sopenharmony_ci  ['-e', '--eval'].forEach(function(evalFlag) {
121cb0ef41Sopenharmony_ci    const args = [checkFlag, evalFlag, 'foo'];
131cb0ef41Sopenharmony_ci    const cmd = [node, ...args].join(' ');
141cb0ef41Sopenharmony_ci    exec(cmd, common.mustCall((err, stdout, stderr) => {
151cb0ef41Sopenharmony_ci      assert.strictEqual(err instanceof Error, true);
161cb0ef41Sopenharmony_ci      assert.strictEqual(err.code, 9);
171cb0ef41Sopenharmony_ci      assert(
181cb0ef41Sopenharmony_ci        stderr.startsWith(
191cb0ef41Sopenharmony_ci          `${node}: either --check or --eval can be used, not both`
201cb0ef41Sopenharmony_ci        )
211cb0ef41Sopenharmony_ci      );
221cb0ef41Sopenharmony_ci    }));
231cb0ef41Sopenharmony_ci  });
241cb0ef41Sopenharmony_ci});
25

Indexes created Thu Nov 07 10:32:03 CST 2024