findYarnVersion(path => { let result = spawnSync( 'node', [path, '--cwd', 'app', 'install', '--force'], options ) if (result.status !== 0) { process.exit(result.status) } result = spawnSync( 'git', ['submodule', 'update', '--recursive', '--init'], options ) if (result.status !== 0) { process.exit(result.status) } result = spawnSync('node', [path, 'compile:tslint'], options) if (result.status !== 0) { process.exit(result.status) } result = spawnSync('node', [path, 'compile:script'], options) if (result.status !== 0) { process.exit(result.status) } })
export function detect(): DartSdkExecutableMap { let sdk: DartSdkExecutableMap; try { const dartExecutable = which.sync('dart'); if (process.platform === 'win32') { sdk = { ANALYZER: 'dartanalyzer.bat', DARTDOCGEN: 'dartdoc.bat', DARTFMT: 'dartfmt.bat', PUB: 'pub.bat', VM: 'dart.exe' }; } else { sdk = { ANALYZER: 'dartanalyzer', DARTDOCGEN: 'dartdoc', DARTFMT: 'dartfmt', PUB: 'pub', VM: 'dart' }; } console.log('Dart SDK detected:', dartExecutable); console.log('- dart: ' + child_process.spawnSync(sdk.VM, ['--version']).stderr.toString().replace(/\n/g, '')); console.log('- pub: ' + child_process.spawnSync(sdk.PUB, ['--version']).stdout.toString().replace(/\n/g, '')); return sdk; } catch (e) { console.log('Dart SDK is not available.'); return null; } }
/** Returns the name and email of the Git user that creates this release build. */ function getCurrentGitUser() { const userName = spawnSync('git', ['config', 'user.name'], {cwd: buildConfig.projectDir}) .stdout.toString().trim(); const userEmail = spawnSync('git', ['config', 'user.email'], {cwd: buildConfig.projectDir}) .stdout.toString().trim(); return `${userName} <${userEmail}>`; }
it('should be able to use the d.ts', async () => { console.log(`${__filename} staging area: ${stagingPath}`); cp.spawnSync('npm', ['pack'], spawnOpts); const tarball = `${pkg.name}-${pkg.version}.tgz`; await (mvp as Function)(tarball, `${stagingPath}/googleapis.tgz`); await ncpp('test/fixtures/kitchen', `${stagingPath}/`); cp.spawnSync( 'npm', ['install'], Object.assign({cwd: `${stagingPath}/`}, spawnOpts) ); }).timeout(80000);
async function setup(): Promise<void> { console.log('*** Test data:', testDataPath); console.log('*** Preparing smoketest setup...'); const keybindingsUrl = `https://raw.githubusercontent.com/Microsoft/vscode-docs/master/scripts/keybindings/doc.keybindings.${getKeybindingPlatform()}.json`; console.log('*** Fetching keybindings...'); await new Promise((c, e) => { https.get(keybindingsUrl, res => { const output = fs.createWriteStream(keybindingsPath); res.on('error', e); output.on('error', e); output.on('close', c); res.pipe(output); }).on('error', e); }); if (!fs.existsSync(workspacePath)) { console.log('*** Creating workspace file...'); const workspace = { folders: [ { path: toUri(path.join(testRepoLocalDir, 'public')) }, { path: toUri(path.join(testRepoLocalDir, 'routes')) }, { path: toUri(path.join(testRepoLocalDir, 'views')) } ] }; fs.writeFileSync(workspacePath, JSON.stringify(workspace, null, '\t')); } if (!fs.existsSync(testRepoLocalDir)) { console.log('*** Cloning test project repository...'); cp.spawnSync('git', ['clone', testRepoUrl, testRepoLocalDir]); } else { console.log('*** Cleaning test project repository...'); cp.spawnSync('git', ['fetch'], { cwd: testRepoLocalDir }); cp.spawnSync('git', ['reset', '--hard', 'FETCH_HEAD'], { cwd: testRepoLocalDir }); cp.spawnSync('git', ['clean', '-xdf'], { cwd: testRepoLocalDir }); } console.log('*** Running npm install...'); cp.execSync('npm install', { cwd: testRepoLocalDir, stdio: 'inherit' }); console.log('*** Smoketest setup done!\n'); }
export function checkInstallation(executable: Executable, projectDir: string) { const child = spawnSync(executable, ['version'], { cwd: projectDir, shell: false, }); return child.status === 0; }
export function spawnSync(tool: string, args: string[], toolchain: Toolchain = 'default', options?: child_process.SpawnOptions) { return child_process.spawnSync(tool, toolchainPrefix(toolchain).concat(args), options); }
function validateWorkspace(): void { try { let spawn = require("child_process").spawnSync; let rubocop = spawn(rubocopPath, ["-f", "j", vscode.workspace.rootPath], { cwd: vscode.workspace.rootPath }); let rubocopOutput = JSON.parse(rubocop.stdout); let arr = []; for (var r = 0; r < rubocopOutput.files.length; r++) { var rubocopFile = rubocopOutput.files[r]; let uri: vscode.Uri = vscode.Uri.file((path.join(vscode.workspace.rootPath, rubocopFile.path))); var offenses = rubocopFile.offenses; let diagnostics: vscode.Diagnostic[] = []; for (var i = 0; i < offenses.length; i++) { let _line = parseInt(offenses[i].location.line) - 1; let _start = parseInt(offenses[i].location.column) - 1; let _end = parseInt(_start + offenses[i].location.length); let diagRange = new vscode.Range(_line, _start, _line, _end); let diagMsg = `${offenses[i].message} (${offenses[i].cop_name})`; let diagSeverity = convertSeverity(offenses[i].severity); let diagnostic = new vscode.Diagnostic(diagRange, diagMsg, diagSeverity); diagnostics.push(diagnostic); } arr.push([uri, diagnostics]); } diagnosticCollection.clear(); diagnosticCollection.set(arr); } catch(err) { console.log(err); } return; }
export default function shellSpawnSync(args) { if (args === 'shell') { args = [platform() === 'win32' ? 'cmd.exe' : 'bash']; } if (prettyPrint) { console.log('::: %s', args.join(' ')); } const child = spawnSync(args[0], args.slice(1), { stdio: 'inherit', cwd: process.cwd(), env: process.env, }); if (child) { if (child.error) { console.error(`can't run command "${args[0]}"\n %s`, child.error.message); return child.status || 127; } else { return child.status; } } else { console.error(`can't run command "${args[0]}"`); return 127; } };
export function checkPublishBranch(version: string) { const versionType = getSemverVersionType(version); const branchName = spawnSync('git', ['symbolic-ref', '--short', 'HEAD'], {cwd: buildConfig.projectDir}).stdout.toString().trim(); if (branchName === 'master') { if (versionType === 'major') { return; } throw `Publishing of "${versionType}" releases should not happen inside of the ` + `${bold('master')} branch.`; } const branchNameMatch = branchName.match(publishBranchNameRegex) || []; const branchDigits = branchNameMatch.slice(1, 4); if (branchDigits[2] === 'x' && versionType !== 'patch') { throw `Cannot publish a "${versionType}" release inside of a patch branch (${branchName})`; } if (branchDigits[1] === 'x' && versionType !== 'minor') { throw `Cannot publish a "${versionType}" release inside of a minor branch (${branchName})`; } throw `Cannot publish a "${versionType}" release from branch: "${branchName}". Releases should ` + `be published from "master" or the according publish branch (e.g. "6.x", "6.4.x")`; }