File tree Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,25 @@ module.exports = async (opt = {}) => {
2424
2525 // runs exec function asynchronously
2626 const execPromise = new Promise ( ( resolve , reject ) => {
27- exec ( cmd , ( error , stdout , stderr ) => {
28- if ( error ) {
29- handleError ( error ) ;
30- reject ( ) ;
31- }
32- resolve ( ) ;
33- } ) ;
27+ if ( typeof cmd !== 'object' ) {
28+ exec ( cmd , ( error , stdout , stderr ) => {
29+ if ( error ) {
30+ handleError ( error ) ;
31+ reject ( ) ;
32+ }
33+ resolve ( ) ;
34+ } ) ;
35+ } else {
36+ cmd . forEach ( command => {
37+ exec ( command , ( error , stdout , stderr ) => {
38+ if ( error ) {
39+ handleError ( error ) ;
40+ reject ( ) ;
41+ }
42+ resolve ( ) ;
43+ } ) ;
44+ } ) ;
45+ }
3446 } ) ;
3547
3648 return execPromise ;
Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ const handleError = require('node-cli-handle-error');
1111 path : `/Users/saadirfan/GitHub` ,
1212 cmd : `touch example.md`
1313 } ) ;
14+
15+ // change directory and run a bunch of commands
16+ const commands = [ `touch example.js` , `touch example.md` ] ;
17+ await execAsync ( {
18+ path : `/Users/saadirfan/GitHub` ,
19+ cmd : commands
20+ } ) ;
1421 } catch ( err ) {
1522 handleError ( err ) ;
1623 }
You canβt perform that action at this time.
0 commit comments