Skip to content

Commit

Permalink
feat: allow multiple context arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Nov 8, 2019
1 parent 4ebb290 commit ef4d728
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ jobs:
- run:
name: test
command: yarn test
- run:
name: release
command: npx semantic-release
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ interface Files {
[filename: string]: string
}

type BundleRunner = (context: any) => Promise<any>
type BundleRunner = (...context: any[]) => Promise<any>

type CreateBundleRunner = (entryFile: string, files: Files, basedir: string, runInNewContext?: boolean | 'once') => BundleRunner
type CreateBundleRunner = (entryFile: string, files: Files, basedir?: string, runInNewContext?: boolean | 'once') => BundleRunner

declare let createBundleRunner: CreateBundleRunner

Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ exports.createBundleRunner = function createBundleRunner(
// module evaluation costs but requires the source code to be structured
// slightly differently.
let runner // lazy creation so that errors can be caught by user
return (userContext = {}) =>
return (...args) =>
new Promise(resolve => {
if (!runner) {
const sandbox = runInNewContext === 'once' ? createSandbox() : global
Expand All @@ -126,7 +126,7 @@ exports.createBundleRunner = function createBundleRunner(
}
}

resolve(runner(userContext))
resolve(runner(...args))
})
}
}

0 comments on commit ef4d728

Please sign in to comment.