Merge pull request #93 from Azure/daschult/DevScripts

Add dev scripts
This commit is contained in:
Dan Schulte 2018-05-17 10:17:31 -07:00 коммит произвёл GitHub
Родитель a6b06917bf ed699232f9
Коммит c4dd6f3211
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 58 добавлений и 2 удалений

44
.scripts/dependencies.js Normal file
Просмотреть файл

@ -0,0 +1,44 @@
const fs = require("fs");
const path = require("path");
/**
* Get the absolute path to the package.json in this repository.
* @returns {string} The absolute path to the package.json.
*/
function getPackageJsonFilePath() {
return path.resolve(__dirname, "../package.json");
}
/**
* Get the package.json file contents parsed as a JSON object.
* @param {string=} packageJsonFilePath The path to the package.json file to read. If this is not
* provided, then the package.json file at the root of this repository will be used.
* @returns {{}} The parsed package.json file contents.
*/
function getPackageJson(packageJsonFilePath) {
if (!packageJsonFilePath) {
packageJsonFilePath = getPackageJsonFilePath();
}
return JSON.parse(fs.readFileSync(packageJsonFilePath));
}
/**
* Update the package.json property values for "main".
* @param {string} mainValue The value that will be used for "main".
* @returns {void}
*/
function updatePackageJsonMain(mainValue) {
const packageJsonFilePath = getPackageJsonFilePath();
const packageJson = getPackageJson(packageJsonFilePath);
if (packageJson.main == mainValue) {
console.log(`"main" is already set to "${mainValue}" in "${packageJsonFilePath}".`);
} else {
console.log(`Changing "main" to "${mainValue}" in "${packageJsonFilePath}"`)
packageJson.main = mainValue;
fs.writeFileSync(packageJsonFilePath, JSON.stringify(packageJson, undefined, " "));
}
}
exports.updatePackageJsonMain = updatePackageJsonMain;

3
.scripts/latest.js Normal file
Просмотреть файл

@ -0,0 +1,3 @@
const dependencies = require("./dependencies");
dependencies.updatePackageJsonMain("./dist/lib/msRest.js")

3
.scripts/local.js Normal file
Просмотреть файл

@ -0,0 +1,3 @@
const dependencies = require("./dependencies");
dependencies.updatePackageJsonMain("./lib/msRest.ts");

3
.scripts/preview.js Normal file
Просмотреть файл

@ -0,0 +1,3 @@
const dependencies = require("./dependencies");
dependencies.updatePackageJsonMain("./dist/lib/msRest.js")

Просмотреть файл

@ -89,6 +89,9 @@
"test:mocha-chrome": "sleep 0.5 && mocha-chrome http://localhost:3001",
"test:chrome-unit": "run-p -r test:server test:mocha-chrome",
"prepare": "npm run build",
"publish-preview": "npm test && shx rm -rf dist/test && node ./.scripts/publish"
"publish-preview": "npm test && shx rm -rf dist/test && node ./.scripts/publish",
"local": "node ./.scripts/local.js",
"preview": "node ./.scripts/preview.js",
"latest": "node ./.scripts/latest.js"
}
}
}