'Why command runs in terminal but not in extension calls?
If in a terminal I run git flow release publish '1.0.0' it is executed successfully.
If I use child_process.spawn in a test.js and then run it with node ./test.js file it also works fine.
But when I use child_process.spawn inside VS Code extension it produces error
fatal: could not read Username for 'https://github.com': No such device or address
If I edit .git/config and add my name https//[email protected]...... then error is
fatal: could not read Password for 'https://github.com': No such device or address.
Here is my code same in test file and VS Code
const spawn = require("child_process").spawn;
let cmd = 'git';
let args = ['flow', 'release', 'publish', '0.2.8'];
// let args = ['flow', 'release', 'delete', '-f', '-r', '0.2.8'];
const child = spawn(cmd, args);
let stdout = [];
let stderr = [];
child.stdout?.on('data', (data) => {
console.log(`[gitflow] Stdout ${data}`);
stdout.push(data.toString());
});
child.stderr?.on('data', (data) => {
console.log(`[gitflow] Stderr ${data}`);
stderr.push(data.toString());
});
child.on('error', err => {
console.log(`[gitflow] Error "${cmd} ${args?.join(" ")}" returned`, err);
});
child.on('spawm', err => {
console.log(`[gitflow] Spawn "${cmd} ${args?.join(" ")}" returned`, err);
});
child.on('exit', code => {
console.log(`[gitflow] Exit "${cmd} ${args?.join(" ")} exited`, code);
});
child.on('close', retc => {
console.log(`[gitflow] Command "${cmd}"`, retc, stderr, stdout);
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
