| 1 |
#!/usr/bin/env node |
| 2 |
/*--------------------------------------------------------------------------------------------- |
| 3 |
* Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 |
* Licensed under the MIT License. See License.txt in the project root for license information. |
| 5 |
*--------------------------------------------------------------------------------------------*/ |
| 6 |
'use strict'; |
| 7 |
|
| 8 |
// @ts-check |
| 9 |
|
| 10 |
const path = require('path'); |
| 11 |
const child_process = require('child_process'); |
| 12 |
|
| 13 |
const root = path.dirname(path.dirname(__dirname)); |
| 14 |
const args = process.argv.slice(2); |
| 15 |
|
| 16 |
// When we install in a package pipeline then we don't want to call install in |
| 17 |
// the project directories since we need to call install there to ensure proper |
| 18 |
// dependency management. |
| 19 |
if (args[0] === 'install' && process.env['npm_config_root_only'] === 'true') { |
| 20 |
return; |
| 21 |
} |
| 22 |
|
| 23 |
/** @type { { folder: string; scripts: string[] }[] } */ |
| 24 |
const folders = [ |
| 25 |
{ folder: 'tools', scripts: ['install', 'clean', 'lint'] }, |
| 26 |
{ folder: 'tsconfig-gen', scripts: ['install', 'clean', 'lint'] }, |
| 27 |
{ folder: 'textDocument', scripts: ['install', 'clean', 'lint', 'test', 'audit'] }, |
| 28 |
{ folder: 'types', scripts: ['install', 'clean', 'lint', 'test', 'audit'] }, |
| 29 |
{ folder: 'jsonrpc', scripts: ['install', 'clean', 'lint', 'test', 'audit'] }, |
| 30 |
{ folder: 'protocol', scripts: ['install', 'clean', 'lint', 'test', 'audit'] }, |
| 31 |
{ folder: 'server', scripts: ['install', 'clean', 'lint', 'test', 'audit'] }, |
| 32 |
{ folder: 'client', scripts: ['install', 'clean', 'lint', 'audit'] }, |
| 33 |
{ folder: 'client-node-tests', scripts: ['install', 'clean', 'lint', 'test', 'audit'] } |
| 34 |
]; |
| 35 |
|
| 36 |
const script = args[0] === 'run' ? args[1] : args[0]; |
| 37 |
|
| 38 |
for (const elem of folders.map(item => { return { folder: item.folder, scripts: new Set(item.scripts) }; } )) { |
| 39 |
if (elem.scripts.has(script)) { |
| 40 |
console.log(path.join(root, elem.folder)); |
| 41 |
child_process.spawnSync(`npm ${args.join(' ')}`, { cwd: path.join(root, elem.folder), shell: true, stdio: 'inherit' }); |
| 42 |
} |
| 43 |
} |