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
}
}
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();
task: () => {
if (!commandExists.sync('kubectl')) {
command.error('E_REQUISITE_NOT_FOUND')
}
}
},
task: (_ctx: any, task: any) => {
if (!commandExists.sync('oc')) {
command.error('E_REQUISITE_NOT_FOUND')
} else {
task.title = `${task.title}...done.`
}
}
},
}
if (process.platform === 'linux') {
return commandExistsSync('chromium-browser');
}
return false;
}
case 'brave': {
if (process.platform === 'darwin') {
const bravePath = path.join('/Applications', 'Brave Browser.app');
return fs.existsSync(bravePath);
}
if (process.platform === 'linux') {
return commandExistsSync('brave-browser');
}
if (process.platform === 'win32') {
const bravePaths = getWin32BravePaths();
return bravePaths.length > 0;
}
return false;
}
case 'vivaldi': {
if (process.platform === 'darwin') {
const bravePath = path.join('/Applications', 'Vivaldi.app');
return fs.existsSync(bravePath);
}
if (process.platform === 'linux') {
webpackMiddleware: {
logLevel: 'warn',
stats: 'errors-only',
},
reporters: ['dots'],
port: 9876,
colors: true,
logLevel: config.LOG_WARN,
browsers: [
commandExists('chromium') ? 'ChromiumHeadless' : 'ChromeHeadless',
],
concurrency: Infinity,
browserConsoleLogOptions: {
level: config.LOG_WARN,
},
});
if (browserStackAvailable) {
const customLaunchers = {};
allBrowsers.forEach(browser => {
customLaunchers[`browserStack${browser[0]}${browser[2]}`] = {
base: 'BrowserStack',
browser: browser[0],
browser_version: browser[1],
ipc.answerRenderer('command-exists', async command => {
const result = await sync(command);
return !!result;
});