Skip to content

Instantly share code, notes, and snippets.

@geta6
Last active October 28, 2015 02:17
Show Gist options
  • Select an option

  • Save geta6/1863dbecfbf5d3e8bce1 to your computer and use it in GitHub Desktop.

Select an option

Save geta6/1863dbecfbf5d3e8bce1 to your computer and use it in GitHub Desktop.

Revisions

  1. geta6 renamed this gist Oct 28, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. geta6 revised this gist Oct 28, 2015. 1 changed file with 29 additions and 0 deletions.
    29 changes: 29 additions & 0 deletions 2.gulpfile.babel.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    gulp.task('exec', () => {
    const exec = {
    exec(command, options) {
    return new Promise((resolve, reject) => {
    cp.spawn(command, options, {stdio: 'inherit'}).on('error', reject).on('exit', resolve);
    });
    },

    local(commands) {
    return this.exec(process.env.SHELL, ['-c', commands.join('&&')]);
    },

    remote(commands) {
    return this.exec('ssh', [process.env.REMOTE_HOST, commands.join('&&')]);
    },
    };

    exec.local([
    'pwd',
    'ls',
    ]).then(() => {
    return exec.remote([
    'pwd',
    'ls',
    ]);
    }).catch(err => {
    console.error(err.stack);
    });
    });
  3. geta6 revised this gist Oct 28, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gulpfile.babel.js
    Original file line number Diff line number Diff line change
    @@ -24,5 +24,4 @@ gulp.task('exec', async () => {
    'pwd',
    'ls',
    ]);

    });
  4. geta6 created this gist Oct 28, 2015.
    28 changes: 28 additions & 0 deletions gulpfile.babel.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    gulp.task('exec', async () => {
    const exec = {
    exec(command, options) {
    return new Promise((resolve, reject) => {
    cp.spawn(command, options, {stdio: 'inherit'}).on('error', reject).on('exit', resolve);
    });
    },

    async local(commands) {
    await this.exec(process.env.SHELL, ['-c', commands.join('&&')]);
    },

    async remote(commands) {
    await this.exec('ssh', [process.env.REMOTE_HOST, commands.join('&&')]);
    },
    };

    await exec.local([
    'pwd',
    'ls',
    ]);

    await exec.remote([
    'pwd',
    'ls',
    ]);

    });