crookedneighbor / npm-unpack

A module to pack and unpack your modules.
2 stars 1 forks source link

Do not interpret shell metacharacters in tarFie when execing tar. #23

Closed mikesamuel closed 6 years ago

mikesamuel commented 6 years ago

Uses child_process.execFile instead of exec. Docs say

The child_process.execFile() function is similar to child_process.exec() except that it does not spawn a shell by default. Rather, the specified executable file is spawned directly as a new process making it slightly more efficient than child_process.exec().

Addresses https://github.com/crookedneighbor/npm-unpack/issues/22

mikesamuel commented 6 years ago

Tests run clean on my machine:

$ npm install && npm test && npm run lint
up to date in 1.291s

> npm-unpack@0.1.0 test /private/tmp/npm-unpack
> npm run lint && mocha

> npm-unpack@0.1.0 lint /private/tmp/npm-unpack
> standard | snazzy

  unpack
    ✓ calls cb with error if module cannot be found
    ✓ calls cb with error if module does not have a package.json
    ✓ calls cb with error if module does not have a valid package.json
    ✓ calls npm pack on the provided path (779ms)
    ✓ calls cb with error if npm pack errors (757ms)
    ✓ logs packed files (771ms)
    ✓ calls cb with error if tar parsing fails (772ms)
    ✓ removes the tar file (776ms)
    ✓ calls cb with error if tar removal fails (772ms)

  npm
    #pack
      ✓ returns the tarred package name (762ms)
      ✓ errors if file cannot be found (729ms)

  tar
    #rm
      ✓ is an alias for rimraf
    #parse
      ✓ returns files in a tgz file
      ✓ errors if file cannot be found

  14 passing (6s)

> npm-unpack@0.1.0 lint /private/tmp/npm-unpack
> standard | snazzy