Skip to content

Commit

Permalink
fix: Fix projectDir pattern in config schema
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Jun 8, 2021
1 parent 58f5215 commit 8954b5f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/configSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const schema = {
},
projectDir: {
type: 'string',
pattern: '/^(\\.\\/?|(\\.\\/)?\\.\\.(\\/\\.\\.)*\\/?)$/',
pattern: '^(\\.\\/?|(\\.\\/)?\\.\\.(\\/\\.\\.)*\\/?)$',
},
/*
* Provider specific properties are extended in respected provider plugins.
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/programmatic/multiService/file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"foo": "bar"
}
7 changes: 7 additions & 0 deletions test/fixtures/programmatic/multiService/serviceA/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports.handler = (event, context, callback) =>
callback(null, {
statusCode: 200,
body: JSON.stringify({}),
});
24 changes: 24 additions & 0 deletions test/fixtures/programmatic/multiService/serviceA/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
service: service

configValidationMode: error
frameworkVersion: '*'

projectDir: ../

provider:
name: aws
runtime: nodejs12.x
lambdaHashingVersion: 20201221

custom:
env: ${env:ENV_SOURCE_TEST, null}
file: ${file(../file.json)}
opt: ${opt:stage, null}
self: ${self:custom.file.foo}
strToBool: ${strToBool('false')}

functions:
foo:
handler: index.handler
other:
handler: index.handler
12 changes: 12 additions & 0 deletions test/unit/scripts/serverless.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ describe('test/unit/scripts/serverless.test.js', () => {
).to.include('nestedInPrototype: bar-in-prototype');
});

it('should support multi service project', async () => {
expect(
String(
(
await spawn('node', [serverlessPath, 'print'], {
cwd: path.resolve(programmaticFixturesPath, 'multiService/serviceA'),
})
).stdoutBuffer
)
).to.include('self: bar');
});

it('should rejected unresolved "provider" section', async () => {
try {
await spawn('node', [serverlessPath, 'print'], {
Expand Down

0 comments on commit 8954b5f

Please sign in to comment.