forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexec-sync.js
30 lines (25 loc) · 885 Bytes
/
exec-sync.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// @ts-check
const path = require('path');
const child_process = require('child_process');
const chalk = require('chalk');
const { logStatus } = require('./logging');
const SEPARATOR = process.platform === 'win32' ? ';' : ':';
/**
* Execute a command synchronously.
*
* @param {string} cmd Command to execute
* @param {string} [displayName] Display name for the command
* @param {string} [cwd] Working directory in which to run the command
*/
function execSync(cmd, displayName, cwd = process.cwd()) {
// delay copying the env so that mods to the process.env are captured
const env = Object.assign({}, process.env);
env.PATH = path.resolve('./node_modules/.bin') + SEPARATOR + env.PATH;
logStatus(chalk.gray('Executing: ') + chalk.cyan(displayName || cmd));
child_process.execSync(cmd, {
cwd,
env,
stdio: 'inherit',
});
}
module.exports = execSync;