rushstack/common/scripts/install-run-rush.js

40 строки
1.9 KiB
JavaScript
Исходник Обычный вид История

2018-06-13 22:07:14 +03:00
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
// This file was generated by a tool. Modifying this file will produce unexpected behavior.
//
// This script is used to install and invoke Rush from a CI definition.
const path = require("path");
const fs = require("fs");
const install_run_common_1 = require("./install-run-common");
const PACKAGE_NAME = '@microsoft/rush';
function getRushVersion() {
const rushJsonDirectory = install_run_common_1.findRushJsonFolder();
const rushJsonPath = path.join(rushJsonDirectory, install_run_common_1.RUSH_JSON_FILENAME);
try {
const rushJsonContents = fs.readFileSync(rushJsonPath, 'UTF-8');
// Use a regular expression to parse out the rushVersion value because rush.json supports comments,
// but JSON.parse does not and we don't want to pull in more dependencies than we need to in this script.
const rushJsonMatches = rushJsonContents.match(/\"rushVersion\"\s*\:\s*\"([0-9a-zA-Z.+\-]+)\"/);
return rushJsonMatches[1];
}
catch (e) {
throw new Error(`Unable to determine the required version of Rush from rush.json (${rushJsonDirectory}). ` +
'The \'rushVersion\' field is either not assigned in rush.json or was specified ' +
'using an unexpected syntax.');
}
}
function run() {
install_run_common_1.runWithErrorPrinting(() => {
// tslint:disable-next-line:no-unused-variable
const [nodePath, scriptPath, packageBinName, ...packageBinArgs] = process.argv;
const version = getRushVersion();
console.log(`Expected Rush version is ${version}`);
install_run_common_1.installAndRun(nodePath, PACKAGE_NAME, version, packageBinName, packageBinArgs);
});
}
run();
//# sourceMappingURL=install-run-rush.js.map