forked from serverless/serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-serverless.js
27 lines (24 loc) · 982 Bytes
/
run-serverless.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
'use strict';
const path = require('path');
const runServerless = require('@serverless/test/run-serverless');
const BbPromise = require('bluebird');
const fixtures = require('../fixtures');
const serverlessPath = path.join(__dirname, '../../');
module.exports = options =>
BbPromise.try(() => {
if (options.fixture && options.cwd) {
throw new Error('Either "fixture" or "cwd" should be provided');
}
const runServerlessOptions = Object.assign({}, options);
delete runServerlessOptions.serverlessPath;
delete runServerlessOptions.fixture;
delete runServerlessOptions.configExt;
const fixturePromise = options.fixture
? fixtures
.setup(options.fixture, { configExt: options.configExt })
.then(({ servicePath }) => (runServerlessOptions.cwd = servicePath))
: BbPromise.resolve();
return fixturePromise.then(() =>
runServerless(options.serverlessPath || serverlessPath, runServerlessOptions)
);
});