-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
32 lines (27 loc) · 1.11 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const path = require('path')
const through = require('through2')
const proxyquire = require('proxyquire')
const util = require('gulp-util')
const commands = require('./commands')
module.exports.exec = (command, options) => {
return through.obj((file, enc, callback) => {
const serviceDirectory = path.dirname(file.path);
util.log('Deploying serverless project from path', serviceDirectory);
process.chdir(serviceDirectory);
const Serverless = proxyquire('serverless', {'./classes/CLI': commands.generate(command).create(options)});
const serverless = new Serverless({});
return serverless.init()
.then(() => { return serverless.run(); })
.then(() => { callback(null, file); })
.catch(error => { callback(error); })
})
}
module.exports.install = (installDevDependencies) => {
return through.obj((file, enc, callback) => {
const serviceDirectory = path.dirname(file.path);
util.log('Installing packages from', serviceDirectory);
commands.install(serviceDirectory, installDevDependencies)
.then(() => { callback(null); })
.catch(error => { callback(error); })
})
}