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

Recognize package.patterns #243

Merged
merged 1 commit into from
Aug 10, 2021
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: 1 addition & 0 deletions src/Serverless.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ declare namespace Serverless {
interface Package {
include: string[]
exclude: string[]
patterns: string[]
artifact?: string
individually?: boolean
}
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export class TypeScriptPlugin {
fn.package = fn.package || {
exclude: [],
include: [],
patterns: []
}

// Add plugin to excluded packages or an empty array if exclude is undefined
Expand Down Expand Up @@ -157,13 +158,14 @@ export class TypeScriptPlugin {
return emitedFiles
}

/** Link or copy extras such as node_modules or package.include definitions */
/** Link or copy extras such as node_modules or package.patterns definitions */
async copyExtras() {
const { service } = this.serverless

const patterns = [...(service.package.include || []), ...(service.package.patterns || [])]
// include any "extras" from the "include" section
if (service.package.include && service.package.include.length > 0) {
const files = await globby(service.package.include)
if (patterns.length > 0) {
const files = await globby(patterns)

for (const filename of files) {
const destFileName = path.resolve(path.join(BUILD_FOLDER, filename))
Expand Down
9 changes: 6 additions & 3 deletions tests/typescript.extractFileName.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@ const functions: { [key: string]: Serverless.Function } = {
handler: 'tests/assets/hello.handler',
package: {
include: [],
exclude: []
exclude: [],
patterns: []
}
},
world: {
handler: 'tests/assets/world.handler',
package: {
include: [],
exclude: []
exclude: [],
patterns: []
}
},
js: {
handler: 'tests/assets/jsfile.create',
package: {
include: [],
exclude: []
exclude: [],
patterns: []
}
},
}
Expand Down