samtsc
Version:
This project was put together to make working with the AWS SAM framework easier for developers. It simplifies working with the SAM framework, using real-time updates to lambda functions, layers and resources. This is done by **samtsc** connecting to the
30 lines (27 loc) • 1.08 kB
JavaScript
const { execSync } = require('child_process');
const { readFileSync } = require('./file-system');
class PluginFramework {
constructor(config, skipPackageLoad) {
this.config = config;
if(!skipPackageLoad) {
const content = readFileSync('package.json').toString().replace(/https?:\/\//g, '\\/\\/').replace(/\/\/.*/g, '');
this.rootPackage = JSON.parse(content);
}
this.execSync = execSync;
}
runHook(hookName) {
if(this.rootPackage && this.rootPackage.scripts &&
this.rootPackage.scripts['samtsc-' + hookName]) {
this.execSync(`npm run samtsc-${hookName}`, {
env: {
config: JSON.stringify(this.config)
}
});
}
}
preTemplateLoad() { this.runHook('pre-template-load'); }
postTemplateLoad() { this.runHook('post-template-load'); }
preCopyIncludes() { this.runHook('pre-copy-includes'); }
postCopyIncludes() { this.runHook('post-copy-includes'); }
}
module.exports.PluginFramework = PluginFramework;