Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove q library #1088

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions node/mock-task.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Q = require('q');
import path = require('path');
import fs = require('fs');
import task = require('./task');
Expand Down Expand Up @@ -331,7 +330,7 @@ export function mv(source: string, dest: string, force: boolean, continueOnError
//-----------------------------------------------------
// Exec convenience wrapper
//-----------------------------------------------------
export function exec(tool: string, args: any, options?: trm.IExecOptions): Q.Promise<number> {
export function exec(tool: string, args: any, options?: trm.IExecOptions): Promise<number> {
var toolPath = which(tool, true);
var tr: trm.ToolRunner = this.tool(toolPath);
if (args) {
Expand Down
104 changes: 2 additions & 102 deletions node/mock-toolrunner.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Q = require('q');
import os = require('os');
import events = require('events');
import ma = require('./mock-answer');
Expand Down Expand Up @@ -268,107 +267,8 @@ export class ToolRunner extends events.EventEmitter {
* @deprecated use `execAsync` instead
* @returns a promise with return code.
*/
public exec(options?: IExecOptions): Q.Promise<number> {
var defer = Q.defer<number>();

this._debug('exec tool: ' + this.toolPath);
this._debug('Arguments:');
this.args.forEach((arg) => {
this._debug(' ' + arg);
});

var success = true;
options = options || <IExecOptions>{};

var ops: IExecOptions = {
cwd: options.cwd || process.cwd(),
env: options.env || process.env,
silent: options.silent || false,
outStream: options.outStream || process.stdout,
errStream: options.errStream || process.stderr,
failOnStdErr: options.failOnStdErr || false,
ignoreReturnCode: options.ignoreReturnCode || false,
windowsVerbatimArguments: options.windowsVerbatimArguments
};

var argString = this.args.join(' ') || '';
var cmdString = this.toolPath;
if (argString) {
cmdString += (' ' + argString);
}

// Using split/join to replace the temp path
cmdString = this.ignoreTempPath(cmdString);

if (!ops.silent) {
if(this.pipeOutputToTool) {
var pipeToolArgString = this.pipeOutputToTool.args.join(' ') || '';
var pipeToolCmdString = this.ignoreTempPath(this.pipeOutputToTool.toolPath);
if(pipeToolArgString) {
pipeToolCmdString += (' ' + pipeToolArgString);
}

cmdString += ' | ' + pipeToolCmdString;
}

ops.outStream.write('[command]' + cmdString + os.EOL);
}

// TODO: filter process.env
var res = mock.getResponse('exec', cmdString, debug);
if (res.stdout) {
this.emit('stdout', res.stdout);
if (!ops.silent) {
ops.outStream.write(res.stdout + os.EOL);
}
const stdLineArray = res.stdout.split(os.EOL);
for (const line of stdLineArray.slice(0, -1)) {
this.emit('stdline', line);
}
if(stdLineArray.length > 0 && stdLineArray[stdLineArray.length - 1].length > 0) {
this.emit('stdline', stdLineArray[stdLineArray.length - 1]);
}
}

if (res.stderr) {
this.emit('stderr', res.stderr);

success = !ops.failOnStdErr;
if (!ops.silent) {
var s = ops.failOnStdErr ? ops.errStream : ops.outStream;
s.write(res.stderr + os.EOL);
}
const stdErrArray = res.stderr.split(os.EOL);
for (const line of stdErrArray.slice(0, -1)) {
this.emit('errline', line);
}
if (stdErrArray.length > 0 && stdErrArray[stdErrArray.length - 1].length > 0) {
this.emit('errline', stdErrArray[stdErrArray.length - 1]);
}
}


var code = res.code;

if (!ops.silent) {
ops.outStream.write('rc:' + res.code + os.EOL);
}

if (code != 0 && !ops.ignoreReturnCode) {
success = false;
}

if (!ops.silent) {
ops.outStream.write('success:' + success + os.EOL);
}
if (success) {
defer.resolve(code);
}
else {
defer.reject(new Error(this.toolPath + ' failed with return code: ' + code));
}

return <Q.Promise<number>>defer.promise;
public exec(options?: IExecOptions): Promise<number> {
return this.execAsync(options);
}

//
Expand Down
11 changes: 0 additions & 11 deletions node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"adm-zip": "^0.5.10",
"minimatch": "3.0.5",
"nodejs-file-downloader": "^4.11.1",
"q": "^1.5.1",
"semver": "^5.7.2",
"shelljs": "^0.8.5",
"uuid": "^3.0.1"
Expand All @@ -39,7 +38,6 @@
"@types/minimatch": "3.0.3",
"@types/mocha": "^9.1.1",
"@types/node": "^16.11.39",
"@types/q": "^1.5.4",
"@types/semver": "^7.3.4",
"@types/shelljs": "^0.8.8",
"mocha": "^9.2.2",
Expand Down
3 changes: 1 addition & 2 deletions node/task.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Q = require('q');
import shell = require('shelljs');
import childProcess = require('child_process');
import fs = require('fs');
Expand Down Expand Up @@ -1534,7 +1533,7 @@ export function execAsync(tool: string, args: any, options?: trm.IExecOptions):
* @param options optional exec options. See IExecOptions
* @returns number
*/
export function exec(tool: string, args: any, options?: trm.IExecOptions): Q.Promise<number> {
export function exec(tool: string, args: any, options?: trm.IExecOptions): Promise<number> {
let tr: trm.ToolRunner = this.tool(tool);
if (args) {
if (args instanceof Array) {
Expand Down
Loading