Skip to content

Commit

Permalink
Fix writing buffers
Browse files Browse the repository at this point in the history
Buffers are not stringified before passed to the archive.
The archiver handles Buffers just fine.

Fixed a typo in .gitignore

Pass ncc options in the same object instead of as a separate argument.
  • Loading branch information
dirkdev98 committed Mar 1, 2019
1 parent 69a7629 commit 029dc45
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typings/
# Optional npm cache directory
.npm

# Optional efslint cache
# Optional eslint cache
.eslintcache

# Optional REPL history
Expand Down
4 changes: 2 additions & 2 deletions src/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import zeitNcc from '@zeit/ncc';

export default async function compile({ inputFilePath }: { inputFilePath: string }, opts: any) {
return zeitNcc(inputFilePath, { minify: false, ...opts });
export default async function compile({ inputFilePath, ...options }: { inputFilePath: string, [key: string]: any }) {
return zeitNcc(inputFilePath, { minify: false, ...options });
}
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class ServerlessPlugin {
const packagingPromises = packageFilesConfig.map(async ({ zip, files }) => {
// For now pass all ncc options directly to ncc. This has the benefit of testing out new
// ncc releases and changes quickly. Later it would be nice to add a validation step in between.
const codeCompilePromises = files.map(({ absPath }) => compiler({ inputFilePath: absPath }, ncc));
const codeCompilePromises = files.map(({ absPath }) => compiler({ inputFilePath: absPath, ...ncc}));
const compiledCodes = await Promise.all(codeCompilePromises);
const zipperFiles = createZipperFiles(files, compiledCodes);
await zipper({ zipPath: zip.absPath, zipContents: zipperFiles });
Expand Down Expand Up @@ -87,8 +87,7 @@ function createZipperFiles(files: IFileNameAndPath[], compiledCodes: CompiledOut
}

content.push({
// Not sure if utf8 is ok, Assets can be of any format...
data: compilerOutput.assets![assetName].source.toString('utf8'),
data: compilerOutput.assets![assetName].source,
name: `${path}${ assetName }`,
})
})
Expand Down
2 changes: 1 addition & 1 deletion src/zipper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs';
import archiver from 'archiver';

export type ZipContent = {
data: string;
data: string | Buffer;
name: string;
}

Expand Down

0 comments on commit 029dc45

Please sign in to comment.