mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
28 lines
982 B
JavaScript
28 lines
982 B
JavaScript
'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)
|
|
);
|
|
});
|