@azure-tools/codegen
Advanced tools
Comparing version 2.1.214 to 2.1.215
@@ -1,4 +0,4 @@ | ||
/// <reference types="node" /> | ||
export declare function cmdlineToArray(text: string, result?: Array<string>, matcher?: RegExp, count?: number): Array<string>; | ||
export declare function resolveFullPath(command: string, alternateRecursiveFolders?: Array<string>): Promise<string | undefined>; | ||
export declare function execute(fullCommandPath: string, cwd: string, ...parameters: Array<string>): Promise<import("child_process").ChildProcessWithoutNullStreams>; | ||
export declare function execute(cwd: string, command: string, ...parameters: Array<string>): Promise<void>; | ||
//# sourceMappingURL=exec.d.ts.map |
@@ -15,2 +15,3 @@ "use strict"; | ||
} | ||
exports.cmdlineToArray = cmdlineToArray; | ||
function getPathVariableName() { | ||
@@ -105,25 +106,43 @@ // windows calls it's path 'Path' usually, but this is not guaranteed. | ||
exports.resolveFullPath = resolveFullPath; | ||
async function execute(fullCommandPath, cwd, ...parameters) { | ||
async function execute(cwd, command, ...parameters) { | ||
const fullCommandPath = await resolveFullPath(command); | ||
if (!fullCommandPath) { | ||
throw new Error(`Unknown command ${command}`); | ||
} | ||
// quote parameters if necessary? | ||
for (let i = 0; i < parameters.length; i++) { | ||
parameters[i] = quoteIfNecessary(parameters[i]); | ||
// parameters[i] = quoteIfNecessary(parameters[i]); | ||
} | ||
if (process.platform === 'win32' && fullCommandPath.indexOf(' ') > -1 && !/.exe$/ig.exec(fullCommandPath)) { | ||
const pathVar = getPathVariableName(); | ||
// preserve the current path | ||
const originalPath = process.env[pathVar]; | ||
try { | ||
// insert the dir into the path | ||
process.env[pathVar] = `${path.dirname(fullCommandPath)}${path.delimiter}${originalPath}`; | ||
// call spawn and return | ||
return child_process_1.spawn(path.basename(fullCommandPath), parameters, { env: process.env, cwd }); | ||
return new Promise((r, j) => { | ||
if (process.platform === 'win32' && fullCommandPath.indexOf(' ') > -1 && !/.exe$/ig.exec(fullCommandPath)) { | ||
const pathVar = getPathVariableName(); | ||
// preserve the current path | ||
const originalPath = process.env[pathVar]; | ||
try { | ||
// insert the dir into the path | ||
process.env[pathVar] = `${path.dirname(fullCommandPath)}${path.delimiter}${originalPath}`; | ||
// call spawn and return | ||
child_process_1.spawn(path.basename(fullCommandPath), parameters, { env: process.env, cwd, stdio: 'inherit' }).on('close', (c, s) => { | ||
if (c) { | ||
j('Command Failed'); | ||
} | ||
r(); | ||
}); | ||
return; | ||
} | ||
finally { | ||
// regardless, restore the original path on the way out! | ||
process.env[pathVar] = originalPath; | ||
} | ||
} | ||
finally { | ||
// regardless, restore the original path on the way out! | ||
process.env[pathVar] = originalPath; | ||
} | ||
} | ||
return child_process_1.spawn(fullCommandPath, parameters, { env: process.env, cwd }); | ||
child_process_1.spawn(fullCommandPath, parameters, { env: process.env, cwd, stdio: 'inherit' }).on('close', (c, s) => { | ||
if (c) { | ||
j('Command Failed'); | ||
} | ||
r(); | ||
}); | ||
return; | ||
}); | ||
} | ||
exports.execute = execute; | ||
//# sourceMappingURL=exec.js.map |
{ | ||
"name": "@azure-tools/codegen", | ||
"version": "2.1.214", | ||
"version": "2.1.215", | ||
"patchOffset": 100, | ||
@@ -5,0 +5,0 @@ "description": "Autorest Code generator common and base classes", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
191461
2449