Skip to content

Commit

Permalink
Merge pull request #6484 from lauw70/lauw70-patch-for-6482
Browse files Browse the repository at this point in the history
Fix invalid path char in GoLang packaging on Windows
  • Loading branch information
pmuens committed Aug 5, 2019
2 parents a2346fa + ffd5058 commit 0296372
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/package/lib/packageService.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ module.exports = {
)
)
.filter(f => f.runtime && f.runtime.startsWith('go'))
.map(f => f.handler);
.map(f => path.normalize(f.handler));

return this.resolveFilePathsAll().then(filePaths =>
this.zipFiles(filePaths, zipFileName, undefined, filesToChmodPlusX).then(filePath => {
Expand Down
26 changes: 25 additions & 1 deletion lib/plugins/package/lib/packageService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,32 @@ describe('#packageService()', () => {
expect(getIncludesStub).to.be.calledOnce,
expect(resolveFilePathsFromPatternsStub).to.be.calledOnce,
expect(zipFilesStub).to.be.calledOnce,
expect(zipFilesStub).to.have.been.calledWithExactly(files, zipFileName, undefined, []),
])
);
}
);

(process.platfrom === 'win32' ? it : it.skip)(
'should normalize the handler path for go runtimes on win32',
() => {
serverless.service.functions.first.handler = 'foo/bar//foo\\bar\\\\foo';
serverless.service.provider.runtime = 'go1.x';

const servicePath = 'test';
const zipFileName = `${serverless.service.service}.zip`;

serverless.config.servicePath = servicePath;

return expect(packagePlugin.packageService()).to.be.fulfilled.then(() =>
BbPromise.all([
expect(getExcludesStub).to.be.calledOnce,
expect(getIncludesStub).to.be.calledOnce,
expect(serverless.service.functions.first),
expect(resolveFilePathsFromPatternsStub).to.be.calledOnce,
expect(zipFilesStub).to.be.calledOnce,
expect(zipFilesStub).to.have.been.calledWithExactly(files, zipFileName, undefined, [
'foo',
path.normalize(serverless.service.functions.first.handler),
]),
])
);
Expand Down

0 comments on commit 0296372

Please sign in to comment.