Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix eslint prettier #518

Merged
merged 4 commits into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ extends:
- plugin:promise/recommended
- plugin:import/errors
- plugin:import/warnings
- prettier
parser: babel-eslint
parserOptions:
sourceType: module
Expand Down
2 changes: 1 addition & 1 deletion .huskyrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"hooks": {
"pre-commit": "lint-staged"
"pre-commit": "lint-staged && npm test"
}
}
5 changes: 2 additions & 3 deletions .lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
linters:
"*.js":
- "eslint --fix" # Run TSLint
- "prettier --write" # Run Prettier
- "npm test" # Run tests
- "prettier-eslint --write" # Run Prettier
- "eslint" # Run TSLint
- "git add"
177 changes: 84 additions & 93 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const packageModules = require('./lib/packageModules');
const lib = require('./lib');

class ServerlessWebpack {

static get lib() {
return lib;
}
Expand All @@ -28,10 +27,10 @@ class ServerlessWebpack {

if (
(_.has(this.serverless, 'service.custom.webpack') &&
_.isString(this.serverless.service.custom.webpack) &&
_.endsWith(this.serverless.service.custom.webpack, '.ts')) ||
_.isString(this.serverless.service.custom.webpack) &&
_.endsWith(this.serverless.service.custom.webpack, '.ts')) ||
(_.has(this.serverless, 'service.custom.webpack.webpackConfig') &&
_.endsWith(this.serverless.service.custom.webpack.webpackConfig, '.ts'))
_.endsWith(this.serverless.service.custom.webpack.webpackConfig, '.ts'))
) {
require('ts-node/register');
}
Expand All @@ -54,139 +53,131 @@ class ServerlessWebpack {
this.commands = {
webpack: {
usage: 'Bundle with Webpack',
lifecycleEvents: [
'webpack'
],
lifecycleEvents: ['webpack'],
options: {
out: {
usage: 'Path to output directory',
shortcut: 'o',
},
shortcut: 'o'
}
},
commands: {
validate: {
type: 'entrypoint',
lifecycleEvents: [
'validate',
],
lifecycleEvents: ['validate']
},
compile: {
type: 'entrypoint',
lifecycleEvents: [
'compile',
],
lifecycleEvents: ['compile'],
commands: {
watch: {
type: 'entrypoint',
lifecycleEvents: [
'compile'
]
lifecycleEvents: ['compile']
}
}
},
package: {
type: 'entrypoint',
lifecycleEvents: [
'packExternalModules',
'packageModules'
],
},
},
},
lifecycleEvents: [ 'packExternalModules', 'packageModules' ]
}
}
}
};

this.hooks = {
'before:package:createDeploymentArtifacts': () => BbPromise.bind(this)
.then(() => this.serverless.pluginManager.spawn('webpack:validate'))
.then(() => this.serverless.pluginManager.spawn('webpack:compile'))
.then(() => this.serverless.pluginManager.spawn('webpack:package')),

'after:package:createDeploymentArtifacts': () => BbPromise.bind(this)
.then(this.cleanup),

'before:deploy:function:packageFunction': () => BbPromise.bind(this)
.then(() => this.serverless.pluginManager.spawn('webpack:validate'))
.then(() => this.serverless.pluginManager.spawn('webpack:compile'))
.then(() => this.serverless.pluginManager.spawn('webpack:package')),

'before:invoke:local:invoke': () => BbPromise.bind(this)
.then(() => {
lib.webpack.isLocal = true;
// --no-build override
if (this.options.build === false) {
this.skipCompile = true;
}
'before:package:createDeploymentArtifacts': () =>
BbPromise.bind(this)
.then(() => this.serverless.pluginManager.spawn('webpack:validate'))
.then(() => this.serverless.pluginManager.spawn('webpack:compile'))
.then(() => this.serverless.pluginManager.spawn('webpack:package')),

'after:package:createDeploymentArtifacts': () => BbPromise.bind(this).then(this.cleanup),

'before:deploy:function:packageFunction': () =>
BbPromise.bind(this)
.then(() => this.serverless.pluginManager.spawn('webpack:validate'))
.then(() => this.serverless.pluginManager.spawn('webpack:compile'))
.then(() => this.serverless.pluginManager.spawn('webpack:package')),

'before:invoke:local:invoke': () =>
BbPromise.bind(this)
.then(() => {
lib.webpack.isLocal = true;
// --no-build override
if (this.options.build === false) {
this.skipCompile = true;
}

return this.serverless.pluginManager.spawn('webpack:validate');
})
.then(() => this.skipCompile ? BbPromise.resolve() : this.serverless.pluginManager.spawn('webpack:compile'))
.then(this.prepareLocalInvoke),
return this.serverless.pluginManager.spawn('webpack:validate');
})
.then(() => (this.skipCompile ? BbPromise.resolve() : this.serverless.pluginManager.spawn('webpack:compile')))
.then(this.prepareLocalInvoke),

'after:invoke:local:invoke': () => BbPromise.bind(this)
.then(() => {
'after:invoke:local:invoke': () =>
BbPromise.bind(this).then(() => {
if (this.options.watch && !this.isWatching) {
return this.watch('invoke:local');
}
return BbPromise.resolve();
}),

'before:run:run': () => BbPromise.bind(this)
.then(() => _.set(this.serverless, 'service.package.individually', false))
.then(() => this.serverless.pluginManager.spawn('webpack:validate'))
.then(() => this.serverless.pluginManager.spawn('webpack:compile'))
.then(this.packExternalModules)
.then(this.prepareRun),
'before:run:run': () =>
BbPromise.bind(this)
.then(() => _.set(this.serverless, 'service.package.individually', false))
.then(() => this.serverless.pluginManager.spawn('webpack:validate'))
.then(() => this.serverless.pluginManager.spawn('webpack:compile'))
.then(this.packExternalModules)
.then(this.prepareRun),

'after:run:run': () => BbPromise.bind(this)
.then(() => {
'after:run:run': () =>
BbPromise.bind(this).then(() => {
if (this.options.watch && !this.isWatching) {
return this.watch(this.watchRun.bind(this));
}
return BbPromise.resolve();
}),

'webpack:webpack': () => BbPromise.bind(this)
.then(() => this.serverless.pluginManager.spawn('webpack:validate'))
.then(() => this.serverless.pluginManager.spawn('webpack:compile'))
.then(() => this.serverless.pluginManager.spawn('webpack:package')),
'webpack:webpack': () =>
BbPromise.bind(this)
.then(() => this.serverless.pluginManager.spawn('webpack:validate'))
.then(() => this.serverless.pluginManager.spawn('webpack:compile'))
.then(() => this.serverless.pluginManager.spawn('webpack:package')),

/*
* Internal webpack events (can be hooked by plugins)
*/
'webpack:validate:validate': () => BbPromise.bind(this)
.then(this.validate),
'webpack:validate:validate': () => BbPromise.bind(this).then(this.validate),

'webpack:compile:compile': () => BbPromise.bind(this)
.then(this.compile),
'webpack:compile:compile': () => BbPromise.bind(this).then(this.compile),

'webpack:compile:watch:compile': () => BbPromise.resolve(),

'webpack:package:packExternalModules': () => BbPromise.bind(this)
.then(this.packExternalModules),

'webpack:package:packageModules': () => BbPromise.bind(this)
.then(this.packageModules),

'before:offline:start': () => BbPromise.bind(this)
.tap(() => {
lib.webpack.isLocal = true;
})
.then(this.prepareOfflineInvoke)
.then(this.wpwatch),

'before:offline:start:init': () => BbPromise.bind(this)
.tap(() => {
lib.webpack.isLocal = true;
})
.then(this.prepareOfflineInvoke)
.then(this.wpwatch),

'before:step-functions-offline:start': () => BbPromise.bind(this)
.tap(() => {
lib.webpack.isLocal = true;
})
.then(this.prepareStepOfflineInvoke)
.then(() => this.serverless.pluginManager.spawn('webpack:compile')),
'webpack:package:packExternalModules': () => BbPromise.bind(this).then(this.packExternalModules),

'webpack:package:packageModules': () => BbPromise.bind(this).then(this.packageModules),

'before:offline:start': () =>
BbPromise.bind(this)
.tap(() => {
lib.webpack.isLocal = true;
})
.then(this.prepareOfflineInvoke)
.then(this.wpwatch),

'before:offline:start:init': () =>
BbPromise.bind(this)
.tap(() => {
lib.webpack.isLocal = true;
})
.then(this.prepareOfflineInvoke)
.then(this.wpwatch),

'before:step-functions-offline:start': () =>
BbPromise.bind(this)
.tap(() => {
lib.webpack.isLocal = true;
})
.then(this.prepareStepOfflineInvoke)
.then(() => this.serverless.pluginManager.spawn('webpack:compile'))
};
}
}
Expand Down
Loading