Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (process.platform === 'win32') {
// Work around spawn not being able to find .bat files.
var joinedArgs = [cmd]
.concat(args)
.map(function(a){
// Add quotes to arguments which contains whitespaces
if (/^[^"].* .*[^"]/.test(a)) return '"' + a + '"';
return a;
}).join(' ');
args = ['/s', '/c'].concat('"' + joinedArgs + '"');
cmd = 'cmd';
opts.windowsVerbatimArguments = true;
}
return Q.Promise(function (resolve, reject) {
var proc = child_process.spawn(cmd, args, opts);
proc.stdout.on('data', process.stdout.write.bind(process.stdout));
proc.stderr.on('data', function (data) {
var suppressThisLine = /^Picked up _JAVA_OPTIONS: /i.test(data.toString());
if (suppressThisLine) {
return;
}
process.stderr.write(data);
});
proc.on('exit', function(code) {
if (code) {
reject('Error code ' + code + ' for command: ' + cmd + ' with args: ' + args);
} else {
return Q.nfcall(client.getAssembly.bind(client), result.assembly_id).then(function callback (result) {
if (superceded) return
if (result.ok !== 'ASSEMBLY_COMPLETED') {
return Q.delay(250).then(() => Q.nfcall(client.getAssembly.bind(client), result.assembly_id)).then(callback)
}
let resulturl = result.results[Object.keys(result.results)[0]][0].url
if (job.out != null) {
outputctl.debug('DOWNLOADING')
return Q.Promise((resolve, reject) => {
http.get(resulturl, res => {
if (res.statusCode !== 200) {
let msg = `Server returned http status ${res.statusCode}`
outputctl.error(msg)
return reject(new Error(msg))
}
if (superceded) return resolve()
res.pipe(job.out)
job.out.on('finish', () => res.unpipe()) // TODO is this done automatically?
resolve(Q.Promise(resolve => {
res.on('end', () => {
resolve(completeJob())
})
}))
public buildReference(doc: vscode.TextDocument, file: string): Q.Promise {
this.ctrl.logger.trace("Entering injectReference() in ext/inject.ts for document: ", doc.fileName, " and file ", file);
return Q.Promise((resolve, reject) => {
this.ctrl.config.getFileLinkInlineTemplate()
.then(tpl =>
this.buildInlineString(
doc,
tpl,
["${title}", J.Util.denormalizeFilename(file, this.ctrl.config.getFileExtension())],
// TODO: reference might refer to other locations
["${link}", "./" + J.Util.getFileInURI(doc.uri.path) + "/" + file]
)
)
.then(inlineString => resolve(inlineString))
.catch(error => {
this.ctrl.logger.error("Failed to inject reference. Reason: ", error);
reject(error);
publishIdentities(people, function () {
var receivePromise = Q.Promise(function (resolve) {
driverTed.once('message', resolve)
})
var rufusRootHash = driverRufus.myRootHash()
var tedRootHash = driverTed.myRootHash()
var billRootHash = driverBill.myRootHash()
var tedMsgHash
contactBoth()
.then(forgetRufus)
.done(function () {
t.end()
})
function contactBoth () {
return Q.all([
function logIn(config, location, options) {
return Q.Promise(function (resolve, reject) {
if (isLoggedIn) {
setLocation(location, options).then(resolve);
return;
}
api.init(config.username, config.password, locWrap(location), config.provider, function (err) {
if (err) {
return reject(err);
}
isLoggedIn = true;
resolve();
});
});
}
public initialize(): Q.Promise {
return Q.Promise((resolve, reject) => {
try {
let ctrl = new J.Util.Ctrl(this.config);
if (ctrl.config.isDevelopmentModeEnabled() == true) {
console.log("Development Mode for Journal extension is enabled, Tracing in Console and Output is activated.");
}
resolve(ctrl);
} catch (error) {
reject(error);
}
});
}
function getInboundWebhooks() {
return q.Promise(function(resolve, reject) {
sp.relayWebhooks.all(function(err, data) {
if (err) {
reject(err);
} else {
resolve(JSON.parse(data.body).results);
}
});
});
}
function httpDiscoveryRequest(to, blob) {
var developerKey = platform.getDeveloperKey();
if (developerKey)
to += '?developer_key=' + developerKey;
var parsed = url.parse(to);
parsed.method = 'POST';
parsed.headers = {};
parsed.headers['Content-Type'] = 'application/json';
return Q.Promise(function(callback, errback) {
var req = getModule(parsed).request(parsed, function(res) {
if (res.statusCode == 404)
return errback(new Error('No such device'));
if (res.statusCode != 200)
return errback(new Error('Unexpected HTTP error ' + res.statusCode));
var data = '';
res.setEncoding('utf8');
res.on('data', function(chunk) {
data += chunk;
});
res.on('end', function() {
callback(data);
});
});
req.on('error', errback);
function uploadDirectoryToS3(options) {
var uploads = [];
return Q.Promise(function(resolve, reject){
dir.files(options.dir, function(err, files){
if (err) {
throw err;
}
options.logger.info("[%s] Files to be uploaded to S3: \n%s", options.buildId, files.join("\n"));
var count = 0;
files.forEach(function(file){
/**
* Ghetto thing: remove the
* first directory from the
* file path.
*
* If you want to archive the
onCreateComment(content) {
CommentActions.createComment.promise(
new Promise((resolve, reject) => {
this.insert({
content,
updatedAt: new Date().getTime()
})
.then(comment => resolve(comment))
.then(() => this.trigger())
.catch(reject);
})
);
},