@@ -15,13 +15,13 @@ const signale_1 = __importDefault(require("signale"));
1515const child_process_1 = require ( "child_process" ) ;
1616const misc_1 = require ( "./misc" ) ;
1717exports . clone = ( context ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
18- yield spawnAsync ( 'ls -lat' ) ;
18+ yield execAsync ( 'ls -lat' ) ;
1919 if ( misc_1 . isGitCloned ( ) )
2020 return ;
2121 const workspace = misc_1 . getWorkspace ( ) ;
2222 const url = misc_1 . getGitUrl ( context ) ;
23- yield spawnAsync ( `git -C ${ workspace } clone --depth=1 --branch=master ${ url } .` ) ;
24- yield spawnAsync ( `git -C ${ workspace } checkout -qf ${ context . sha } ` ) ;
23+ yield execAsync ( `git -C ${ workspace } clone --depth=1 --branch=master ${ url } .` ) ;
24+ yield execAsync ( `git -C ${ workspace } checkout -qf ${ context . sha } ` ) ;
2525} ) ;
2626exports . runBuild = ( ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
2727 const commands = misc_1 . getBuildCommands ( ) ;
@@ -31,29 +31,23 @@ exports.runBuild = () => __awaiter(this, void 0, void 0, function* () {
3131 const current = process . cwd ( ) ;
3232 signale_1 . default . info ( 'workspace=%s' , workspace ) ;
3333 signale_1 . default . info ( 'current=%s' , current ) ;
34- yield spawnAsync ( `cd ${ workspace } ` ) ;
34+ yield execAsync ( `cd ${ workspace } ` ) ;
3535 for ( const command of commands ) {
36- yield spawnAsync ( command ) ;
36+ yield execAsync ( command ) ;
3737 }
38- yield spawnAsync ( `cd ${ current } ` ) ;
38+ yield execAsync ( `cd ${ current } ` ) ;
3939} ) ;
4040exports . getDiffFiles = ( ) => __awaiter ( this , void 0 , void 0 , function * ( ) {
4141 const workspace = misc_1 . getWorkspace ( ) ;
42- yield spawnAsync ( `git -C ${ workspace } add --all` ) ;
43- yield spawnAsync ( `git -C ${ workspace } status --short -uno` ) ;
44- return ( yield spawnAsync ( `git -C ${ workspace } status --short -uno` ) ) . split ( / \r \n | \n / ) . filter ( line => line . match ( / ^ [ M D A ] \s + / ) ) . map ( line => line . replace ( / ^ [ M D A ] \s + / , '' ) ) ;
42+ yield execAsync ( `git -C ${ workspace } add --all` ) ;
43+ yield execAsync ( `git -C ${ workspace } status --short -uno` ) ;
44+ return ( yield execAsync ( `git -C ${ workspace } status --short -uno` ) ) . split ( / \r \n | \n / ) . filter ( line => line . match ( / ^ [ M D A ] \s + / ) ) . map ( line => line . replace ( / ^ [ M D A ] \s + / , '' ) ) ;
4545} ) ;
46- const spawnAsync = ( command ) => new Promise ( ( resolve , reject ) => {
46+ const execAsync = ( command ) => new Promise ( ( resolve , reject ) => {
4747 signale_1 . default . info ( `Run command: ${ command } ` ) ;
48- const process = child_process_1 . spawn ( command ) ;
49- let output = '' ;
50- process . stdout . on ( 'data' , data => {
51- console . log ( data ) ;
52- output += data ;
53- } ) ;
54- process . on ( 'close' , code => {
55- if ( code !== 0 )
56- reject ( new Error ( `command ${ command } exited with code ${ code } .` ) ) ;
57- resolve ( output ) ;
48+ child_process_1 . exec ( command , ( error , stdout ) => {
49+ if ( error )
50+ reject ( new Error ( `command ${ command } exited with code ${ error } .` ) ) ;
51+ resolve ( stdout ) ;
5852 } ) ;
5953} ) ;
0 commit comments