isolated-function 0.1.37 → 0.1.38

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.37",
5
+ "version": "0.1.38",
6
6
  "types": "src/index.d.ts",
7
7
  "main": "src/index.js",
8
8
  "exports": {
@@ -6,20 +6,22 @@ const path = require('path')
6
6
  const transformDependencies = require('./transform-dependencies')
7
7
  const installDependencies = require('./install-dependencies')
8
8
  const detectDependencies = require('./detect-dependencies')
9
- const { duration } = require('../debug')
9
+ const { debug, duration } = require('../debug')
10
10
  const template = require('../template')
11
11
  const build = require('./build')
12
12
 
13
13
  const tmpdirDefault = async () => {
14
+ const duration = debug.duration()
14
15
  const cwd = await fs.mkdtemp(path.join(require('os').tmpdir(), 'compile-'))
15
16
  await fs.mkdir(cwd, { recursive: true })
16
17
  const cleanup = () => fs.rm(cwd, { recursive: true, force: true })
18
+ duration('tmpdir', { cwd })
17
19
  return { cwd, cleanup }
18
20
  }
19
21
 
20
22
  module.exports = async (snippet, tmpdir = tmpdirDefault) => {
21
23
  let content = template(snippet)
22
- const { cwd, cleanup } = await duration('tmpdir', tmpdir)
24
+ const { cwd, cleanup } = await tmpdir()
23
25
 
24
26
  const dependencies = detectDependencies(content)
25
27
  if (dependencies.length) {
@@ -1,9 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const { execSync } = require('child_process')
4
- const { writeFile } = require('fs/promises')
5
4
  const $ = require('tinyspawn')
6
- const path = require('path')
7
5
 
8
6
  const install = (() => {
9
7
  try {
@@ -17,6 +15,5 @@ const install = (() => {
17
15
  })()
18
16
 
19
17
  module.exports = async ({ dependencies, cwd }) => {
20
- await writeFile(path.join(cwd, 'package.json'), '{}')
21
18
  return $(`${install} ${dependencies.join(' ')}`, { cwd })
22
19
  }
package/src/index.js CHANGED
@@ -49,8 +49,8 @@ module.exports = (snippet, { tmpdir, timeout, memory, throwError = true, allow =
49
49
  const { isFulfilled, value, profiling, logging } = JSON.parse(stdout)
50
50
  profiling.duration = duration()
51
51
  debug('node', {
52
- duration: `${Math.round(profiling.duration / 100)}s`,
53
- memory: `${Math.round(profiling.memory / (1024 * 1024))}MiB`
52
+ memory: `${Math.round(profiling.memory / (1024 * 1024))}MiB`,
53
+ duration: `${Math.round(profiling.duration / 100)}s`
54
54
  })
55
55
 
56
56
  return isFulfilled