Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then((json) => {
// we need this tool, so save its path right now
// const cmi = resolve(join('node_modules', '.bin', 'commit-message-install'))
// need to clone entire repo so we get all branches
// because we might be testing in a separate branch
execa.sync(`git clone ${url} ${localFolder}`, execOptions)
console.log('cloned into folder %s', localFolder)
shell.cd(localFolder)
const branch = json && json.branch
if (branch) {
console.log('commit message specifies branch to test', branch)
console.log('trying to switch to remote branch', branch)
const cmd = `git checkout ${branch}`
try {
execa.sync(cmd, execOptions)
} catch (e) {
console.error('Caught error trying to do', cmd)
console.error(e.message)
console.error('assuming we can work in the default branch')
});
if (process.platform === 'darwin') {
try {
return execa.sync(
'open',
['-a', terminal, launchPackagerScript],
procConfig,
);
} catch (error) {
return execa.sync('open', [launchPackagerScript], procConfig);
}
}
if (process.platform === 'linux') {
try {
return execa.sync(terminal, ['-e', `sh ${launchPackagerScript}`], {
...procConfig,
detached: true,
});
} catch (error) {
// By default, the child shell process will be attached to the parent
return execa.sync('sh', [launchPackagerScript], procConfig);
}
}
if (/^win/.test(process.platform)) {
//Temporary fix for #484. See comment on line 254
fs.writeFileSync(launchPackagerScript, launchPackagerScriptContent, {
encoding: 'utf8',
flag: 'w',
});
// Awaiting this causes the CLI to hang indefinitely, so this must execute without await.
function npmCheck() {
const version = execa.sync('npm', ['-v']).stdout;
const versions = version.split('.');
if (versions[0] !== '5' || !['4', '5', '6'].includes(versions[1])) {
return;
}
console.log('升级 npm');
if (process.platform === 'win32') {
execa.sync('npm', ['install', 'npm', '-g']);
} else {
execa.sync('sudo', ['npm', 'install', 'npm', '-g']);
}
}
function isUsingBatteryWindows() {
try {
const { stdout } = execa.sync('wmic', [
'/namespace:',
'\\\\root\\WMI',
'path',
'BatteryStatus',
'get',
'PowerOnline',
'/format:list',
]);
return /\bPowerOnline=FALSE\b/.test(stdout);
} catch (ex) {
logger.warn(`Could not get battery status from wmic: ${ex}`);
logger.warn(ex.stack);
return null;
}
const fs = require('fs');
const path = require('path');
const execa = require('execa');
const devUtils = require('@kbn/dev-utils');
const { DLL_OUTPUT } = require('./../.storybook/constants');
const log = new devUtils.ToolingLog({
level: 'info',
writeTo: process.stdout,
});
if (fs.existsSync(DLL_OUTPUT)) {
log.info('storybook: DLL exists from previous build');
} else {
log.info('storybook: DLL missing; building');
execa.sync(
'yarn',
[
'webpack',
'--config',
'x-pack/legacy/plugins/canvas/.storybook/webpack.dll.config.js',
'--progress',
'--hide-modules',
'--display-entrypoints',
'false',
],
{
cwd: path.resolve(__dirname, '../../../../..'),
stdio: ['ignore', 'inherit', 'inherit'],
buffer: false,
}
);
const buildDirectory = `${appFolder}/build/outputs/apk/${variant}`;
const apkFile = getInstallApkName(
appFolder,
adbPath,
variant,
device,
buildDirectory,
);
const pathToApk = `${buildDirectory}/${apkFile}`;
const adbArgs = ['-s', device, 'install', '-r', '-d', pathToApk];
logger.info(`Installing the app on the device "${device}"...`);
logger.debug(
`Running command "cd android && adb -s ${device} install -r -d ${pathToApk}"`,
);
execa.sync(adbPath, adbArgs, {stdio: 'inherit'});
} catch (error) {
throw new CLIError('Failed to install the app on the device.', error);
}
}
const envVariable = getEnvironmentVariable();
if (envVariable) {
return envVariable;
}
const userInfoUsername = getUsernameFromOsUserInfo();
if (userInfoUsername) {
return userInfoUsername;
}
try {
if (process.platform === 'win32') {
return cleanWindowsCommand(execa.sync('whoami').stdout);
}
const userId = execa.sync('id', ['-u']).stdout;
try {
return execa.sync('id', ['-un', userId]).stdout;
} catch (_) {}
return makeUsernameFromId(userId);
} catch (_) {}
});
function execWithLog(command, force) {
debug(chalk.cyan('Executing: ') + chalk.yellow(command));
if (debug.enabled || force) {
return execa.sync(command, { stdio: [0, 1, 2], shell: true });
}
return execa.sync(command, { shell: true }).stdout;
}
const sync = family => {
const {stdout} = execa.sync("netstat", args[family]);
return parse(stdout);
};
return __generator(this, function (_a) {
webtorrentOptions = utils_1.default.webtorrent.options.parse(webtorrentOptions, config_1.default.webtorrent.options);
execArgs = ['download', torrent].concat(webtorrentOptions), execOpts = {
cwd: path.resolve(__dirname, '..'),
stdio: 'inherit'
};
execa.sync('webtorrent', execArgs, execOpts);
return [2 /*return*/];
});
});