weixu365 / serverless-scriptable-plugin

Adding script support to Serverless 1.x which enables you to customize Serverless behavior without writing a plugin.
MIT License
111 stars 11 forks source link

Allow bash execuption #1

Closed schabert closed 7 years ago

schabert commented 7 years ago

Hi, i have used your plugin and it is a good help for my project.

But the scriptable plugin is only limited to execute javascript files.

Could it be a good extension to allow any kind of scripts? The code that could handle that:

const execSync = require('child_process').execSync;
function exec(description, command) {
    console.log(`Package: ${description} : ${command}`);
    var output = execSync(command).toString('utf8');

    if (output) {
        console.log(output);
    }
}

And the configuration in the serverless.yml could look like

custom:
  scriptHooks:
    before:deploy:createDeploymentArtifacts: make deploy

This would increase the reusability in many different projects programming language independent. In our case we want to execute python scripts that are execute before some kind of deployment

weixu365 commented 7 years ago

Thanks for your request, I have added this feature in 0.3.0. You can try it now, with the same usage as you wrote.

The logic is: if the command exists, execute it as a javascript file, else execute as a bash script.