Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var request = require("request");
var chalk = require("chalk");
var figures = require("figures");
var args = require("args");
var commandExists = require("command-exists");
// list of supported package manager tools
// the first one found will be default
var tools = {
yarn: { command: 'yarn add -D' },
npm: { command: 'npm install -D' }
};
// look for the first available tool
var defaultTool;
for (var _i = 0, _a = Object.keys(tools); _i < _a.length; _i++) {
var tool_1 = _a[_i];
if (commandExists.sync(tool_1)) {
defaultTool = tool_1;
break;
}
}
if (defaultTool === undefined) {
console.error('Couldn\'t find a supported package manager tool.');
}
// support for overriding default
args.option('tool', 'Which package manager tool to use', defaultTool);
var opts = args.parse(process.argv, {
name: 'ts-typie',
mri: undefined,
mainColor: 'yellow',
subColor: 'dim'
});
var tool = tools[opts.tool];
function release_win(arch, done) {
// Check if makensis exists
if (!commandExistsSync('makensis')) {
console.warn('makensis command not found, not generating win package for ' + arch);
return done();
}
// The makensis does not generate the folder correctly, manually
createDirIfNotExists(RELEASE_DIR);
// Parameters passed to the installer script
const options = {
verbose: 2,
define: {
'VERSION': pkg.version,
'PLATFORM': arch,
'DEST_FOLDER': RELEASE_DIR
}
}
const isParityInPath = async () => {
const parityCommandExists = await commandExists('parity');
if (parityCommandExists) {
// If yes, return `parity` as command to launch parity
return 'parity';
} else {
throw new Error('Parity not in path.');
}
};
export async function findDfuPath() {
const win32 = process.platform === 'win32';
const name = win32 ? 'dfu-util.exe' : 'dfu-util';
// Prefer the configurator downloaded version (they can always override)
const localpath = path.join(paths.utils, `dfu-util_v${info.version}`, win32 ? 'dfu-util.exe' : 'dfu-util');
try {
await access(localpath);
return localpath;
} catch {
// Just swallow
}
try {
const onPath = await commandExists(name);
if (onPath) {
return 'dfu-util';
}
} catch {
// Just swallow
}
return '';
}
const isParityInPath = async () => {
const parityCommandExists = await commandExists('parity');
if (parityCommandExists) {
// If yes, return `parity` as command to launch parity
return 'parity';
}
};
installing() {
const prevValue = process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD
process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = '1'
commandExists('yarn', (err: null | Error, exists: boolean) => {
if (exists) {
this.yarnInstall()
} else {
this.npmInstall()
}
})
process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = prevValue
}
ncp.ncp(path.join(__dirname, '../template/'), dir, err => {
if (err) {
reject(err);
return;
}
exists('yarn', (error, status) => {
if (error) {
reject(error);
return;
}
try {
console.log(
`🍭 Installing ${chalk.bold('react')} and ${chalk.bold(
'react-dom'
)}`
);
if (status) {
execSync('yarn add react react-dom', { cwd: dir });
} else {
execSync('npm install -S react react-dom', { cwd: dir });
task: () => {
if (!commandExists.sync('kubectl')) {
command.error('E_REQUISITE_NOT_FOUND')
}
}
},
function getBinary(): string {
let jxConfig = vscode.workspace.getConfiguration("jx",
vscode.window.activeTextEditor ? vscode.window.activeTextEditor.document.uri : null);
var jxPath = '';
if (jxConfig) {
jxPath = jxConfig['path'];
}
var binary = 'jx';
var exists = require('command-exists');
if (jxPath !== null && jxPath !== '' && typeof jxPath !== 'undefined') {
binary = path.join(jxPath, binary);
if (!exists.sync(binary)) {
vscode.window.showErrorMessage('Failed to find the jx binary in your "jx.path" setting.');
return "";
}
} else {
if (!exists.sync(binary)) {
vscode.window.showErrorMessage('Failed to find the jx binary in your PATH. You can specify its path in "jx.path" setting')
return "";
}
}
return binary;
}
function start() {
if (!spawnSync) {
throw new Error(
'Sync-request requires node version 0.12 or later. If you need to use it with an older version of node\n' +
'you can `npm install sync-request@2.2.0`, which was the last version to support older versions of node.'
);
}
try {
if (commandExists.sync('nc')) {
const findPortResult = spawnSync(process.execPath, [require.resolve('./lib/find-port')]);
if (findPortResult.status !== 0) {
throw new Error(
findPortResult.stderr.toString() ||
('find port exited with code ' + findPortResult.status)
);
}
if (findPortResult.error) {
if (typeof findPortResult.error === 'string') {
throw new Error(findPortResult.error);
}
throw findPortResult.error;
}
const ncPort = findPortResult.stdout.toString('utf8').trim();
const p = spawn(process.execPath, [require.resolve('./lib/nc-server'), ncPort], {stdio: 'inherit'});
p.unref();