forked from Azure/azure-sdk-for-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Azure#93 from Azure/daschult/DevScripts
Add dev scripts
- Loading branch information
Showing
5 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const dependencies = require("./dependencies"); | ||
|
||
dependencies.updatePackageJsonMain("./dist/lib/msRest.js") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const dependencies = require("./dependencies"); | ||
|
||
dependencies.updatePackageJsonMain("./lib/msRest.ts"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const dependencies = require("./dependencies"); | ||
|
||
dependencies.updatePackageJsonMain("./dist/lib/msRest.js") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters