Page MenuHomePhorge

test_child_process_execfile_git_options.cjs
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

test_child_process_execfile_git_options.cjs

const { promisify } = require('node:util');
const { execFile } = require('node:child_process');
const path = require('node:path');
async function main() {
const execFileAsync = promisify(execFile);
const cwd = path.join(__dirname, '..');
const revParse = await execFileAsync(
'git',
['rev-parse', '--show-toplevel'],
{ cwd, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 }
);
if (!revParse || typeof revParse.stdout !== 'string') {
throw new Error('expected rev-parse stdout string');
}
if (!revParse.stdout.trim().endsWith('/ant')) {
throw new Error(`unexpected rev-parse output: ${JSON.stringify(revParse.stdout)}`);
}
const status = await execFileAsync(
'git',
['status', '--porcelain=v1', '-z', '--untracked-files=normal'],
{ cwd, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 }
);
if (!status || typeof status.stdout !== 'string') {
throw new Error('expected status stdout string');
}
console.log('util.promisify(execFile) handles git with options');
}
main().catch((err) => {
console.error(err && err.stack ? err.stack : String(err));
process.exit(1);
});

File Metadata

Mime Type
application/javascript
Expires
Fri, May 1, 11:33 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
542973
Default Alt Text
test_child_process_execfile_git_options.cjs (1 KB)

Event Timeline