MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 38 lines 1.1 kB view raw
1const { promisify } = require('node:util'); 2const { execFile } = require('node:child_process'); 3const path = require('node:path'); 4 5async function main() { 6 const execFileAsync = promisify(execFile); 7 const cwd = path.join(__dirname, '..'); 8 9 const revParse = await execFileAsync( 10 'git', 11 ['rev-parse', '--show-toplevel'], 12 { cwd, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 } 13 ); 14 15 if (!revParse || typeof revParse.stdout !== 'string') { 16 throw new Error('expected rev-parse stdout string'); 17 } 18 if (!revParse.stdout.trim().endsWith('/ant')) { 19 throw new Error(`unexpected rev-parse output: ${JSON.stringify(revParse.stdout)}`); 20 } 21 22 const status = await execFileAsync( 23 'git', 24 ['status', '--porcelain=v1', '-z', '--untracked-files=normal'], 25 { cwd, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 } 26 ); 27 28 if (!status || typeof status.stdout !== 'string') { 29 throw new Error('expected status stdout string'); 30 } 31 32 console.log('util.promisify(execFile) handles git with options'); 33} 34 35main().catch((err) => { 36 console.error(err && err.stack ? err.stack : String(err)); 37 process.exit(1); 38});