forked from hyoo-ru/mam_mol
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexec.node.ts
More file actions
33 lines (28 loc) · 686 Bytes
/
exec.node.ts
File metadata and controls
33 lines (28 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace $ {
export function $mol_exec(
this : $mol_ambient_context ,
dir : string ,
command : string ,
...args : string[]
) {
let [ app , ... args0 ] = command.split( ' ' )
args = [ ... args0 , ... args ]
this.$mol_log3_come({
place: '$mol_exec' ,
dir: $node.path.relative( '' , dir ) ,
message: 'Run',
command: `${app} ${ args.join(' ') }` ,
})
var res = $node['child_process'].spawnSync(
app ,
args,
{
cwd : $node.path.resolve( dir ) ,
shell : true ,
}
)
if( res.status || res.error ) return $mol_fail( res.error || new Error( res.stderr.toString() ) )
if( !res.stdout ) res.stdout = new Buffer('')
return res
}
}