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 symlink creation #130

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ plugin as follows:

Run `serverless offline start`.

#### serverless-plugin-simulate

Add the plugins to your `serverless.yml` file and make sure that `serverless-plugin-typescript`
precedes `serverless-plugin-simulate` as the order is important:
```yaml
plugins:
...
- serverless-plugin-typescript
...
- serverless-simulate-simulate
...
```

`serverless-plugin-typescript` attaches to `simulate lambda` and `simulate apigateway` events

#### Other useful options

You can reduce the clutter generated by `serverless-offline` with `--dontPrintOutput` and
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export class TypeScriptPlugin {
await this.compileTs()
this.watchAll()
},
'before:simulate:lambda:start': this.compileTs.bind(this),
'before:simulate:apigateway:initialize': this.compileTs.bind(this),
'before:package:createDeploymentArtifacts': this.compileTs.bind(this),
'after:package:createDeploymentArtifacts': this.cleanup.bind(this),
'before:deploy:function:packageFunction': this.compileTs.bind(this),
Expand Down Expand Up @@ -138,12 +140,12 @@ export class TypeScriptPlugin {
async copyExtras() {
// include node_modules into build
if (!fs.existsSync(path.resolve(path.join(buildFolder, 'node_modules')))) {
fs.symlinkSync(path.resolve('node_modules'), path.resolve(path.join(buildFolder, 'node_modules')))
fs.symlinkSync(path.resolve('node_modules'), path.resolve(path.join(buildFolder, 'node_modules')), 'dir')
}

// include package.json into build so Serverless can exlcude devDeps during packaging
if (!fs.existsSync(path.resolve(path.join(buildFolder, 'package.json')))) {
fs.symlinkSync(path.resolve('package.json'), path.resolve(path.join(buildFolder, 'package.json')))
fs.symlinkSync(path.resolve('package.json'), path.resolve(path.join(buildFolder, 'package.json')), 'file')
}

// include any "extras" from the "include" section
Expand Down