From cf0249a39ddd90c31943b15e92d430488c5187f1 Mon Sep 17 00:00:00 2001 From: Will Temple Date: Mon, 22 Mar 2021 17:21:28 -0700 Subject: [PATCH] [eng] Removed common/scripts/npm-run-project.js (#14414) * [eng] Removed common/scripts/npm-run-project.js This script is broken and doesn't work on Windows. It's only used in one place, so replace it with install-run-rushx.js * This convention for expanding variables is weird. --- common/scripts/npm-run-project.js | 49 ------------------- .../jobs/archetype-sdk-integration.yml | 3 +- 2 files changed, 2 insertions(+), 50 deletions(-) delete mode 100644 common/scripts/npm-run-project.js diff --git a/common/scripts/npm-run-project.js b/common/scripts/npm-run-project.js deleted file mode 100644 index 008bb538c1ef..000000000000 --- a/common/scripts/npm-run-project.js +++ /dev/null @@ -1,49 +0,0 @@ -const fs = require("fs"); -const process = require("process"); -const childProcess = require("child_process"); -const parse = require("../lib/jju/parse").parse; - -function read(filename) { - const txt = fs.readFileSync(filename, "utf8"); - return parse(txt); -} - -const [ - nodePath, - /* Ex: /bin/node */ scriptPath, - /* /repo/common/scripts/npm-run-project.js */ projectName, - /* myproject */ ...scriptNameAndArgs /* [lint, --fix] */ -] = process.argv; -if (!nodePath || !scriptPath) { - throw new Error("Unexpected exception: could not detect node path or script path"); -} -if (process.argv.length < 3) { - console.error("Usage: npm-run-project.js [args...]"); - console.error("Example: npm-run-project.js myproject lint --fix"); - process.exit(1); -} - -const rush = read(`${__dirname}/../../rush.json`); -let workingDir; -for (const each of rush.projects) { - if (each.packageName == projectName) { - workingDir = each.projectFolder; - break; - } -} -if (!workingDir) { - console.error(`Project ${projectName} not found in rush.json`); - process.exit(1); -} - -try { - const result = childProcess.spawnSync("npm", ["run", ...scriptNameAndArgs], { - stdio: "inherit", - cwd: workingDir, - env: process.env - }); - process.exit(result.status); -} catch (e) { - console.error(`\n\n${e.toString()}\n\n`); - process.exit(1); -} diff --git a/eng/pipelines/templates/jobs/archetype-sdk-integration.yml b/eng/pipelines/templates/jobs/archetype-sdk-integration.yml index 0deaaa70a811..b58daf1e07f7 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-integration.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-integration.yml @@ -146,8 +146,9 @@ jobs: - ${{ parameters.PostSteps }} - script: | - node common/scripts/npm-run-project.js "${{parameters.PackageName}}" execute:samples + node ../../../common/scripts/install-run-rushx.js execute:samples displayName: "Execute Samples" + workingDirectory: $(PackagePath) env: TEST_MODE: "live" ${{ insert }}: ${{ parameters.EnvVars }}