isolated-function 0.1.22 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "isolated-function",
3
3
  "description": "Runs untrusted code in a Node.js v8 sandbox.",
4
4
  "homepage": "https://github.com/Kikobeats/isolated-function",
5
- "version": "0.1.22",
5
+ "version": "0.1.23",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js"
@@ -76,6 +76,9 @@
76
76
  "test": "c8 ava"
77
77
  },
78
78
  "license": "MIT",
79
+ "ava": {
80
+ "workerThreads": false
81
+ },
79
82
  "commitlint": {
80
83
  "extends": [
81
84
  "@commitlint/config-conventional"
@@ -20,18 +20,20 @@ const tmpdirDefault = async () => {
20
20
  module.exports = async (snippet, tmpdir = tmpdirDefault) => {
21
21
  const compiledTemplate = generateTemplate(snippet)
22
22
  const dependencies = detectDependencies(compiledTemplate)
23
+ let content = transformDependencies(compiledTemplate)
24
+ let cleanupPromise
23
25
 
24
- const content = transformDependencies(compiledTemplate)
25
- const tmpDir = await duration('tmpdir', tmpdir)
26
- await duration('npm:install', () => installDependencies({ dependencies, cwd: tmpDir.cwd }), {
27
- dependencies
28
- })
29
- const result = await duration('esbuild', () => build({ content, cwd: tmpDir.cwd }))
30
-
31
- return {
32
- content: result.outputFiles[0].text,
33
- cleanupPromise: duration('tmpDir:cleanup', tmpDir.cleanup)
26
+ if (dependencies.length) {
27
+ const { cwd, cleanup } = await duration('tmpdir', tmpdir)
28
+ await duration('npm:install', () => installDependencies({ dependencies, cwd }), {
29
+ dependencies
30
+ })
31
+ const result = await duration('esbuild', () => build({ content, cwd }))
32
+ content = result.outputFiles[0].text
33
+ cleanupPromise = duration('tmpDir:cleanup', cleanup)
34
34
  }
35
+
36
+ return { content, cleanupPromise }
35
37
  }
36
38
 
37
39
  module.exports.detectDependencies = detectDependencies