setDevDependencyVersion.js 785 B

12345678910111213141516171819
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. //@ts-check
  6. const fs = require('fs');
  7. if (process.argv.length !== 5) {
  8. console.error(
  9. `usage: node setDevDependencyVersion.js <PATH_TO_PACKAGE_JSON_FILE> <PACKAGE> <VERSION>`
  10. );
  11. process.exit(1);
  12. }
  13. const packagejson = JSON.parse(fs.readFileSync(process.argv[2]).toString());
  14. packagejson['devDependencies'][process.argv[3]] = process.argv[4];
  15. fs.writeFileSync(process.argv[2], JSON.stringify(packagejson, null, '\t') + '\n');