cross-zip 4.0.0 → 4.0.1

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.
@@ -0,0 +1,15 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: npm
4
+ directory: /
5
+ schedule:
6
+ interval: daily
7
+ labels:
8
+ - dependency
9
+ versioning-strategy: increase-if-necessary
10
+ - package-ecosystem: github-actions
11
+ directory: /
12
+ schedule:
13
+ interval: daily
14
+ labels:
15
+ - dependency
@@ -0,0 +1,23 @@
1
+ name: ci
2
+ 'on':
3
+ - push
4
+ - pull_request
5
+ jobs:
6
+ test:
7
+ name: Node ${{ matrix.node }} / ${{ matrix.os }}
8
+ runs-on: ${{ matrix.os }}
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ os:
13
+ - ubuntu-latest
14
+ node:
15
+ - '14'
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - uses: actions/setup-node@v2
19
+ with:
20
+ node-version: ${{ matrix.node }}
21
+ - run: npm install
22
+ - run: npm run build --if-present
23
+ - run: npm test
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # cross-zip [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
1
+ # cross-zip [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
2
2
 
3
- [travis-image]: https://img.shields.io/travis/feross/cross-zip/master.svg
4
- [travis-url]: https://travis-ci.org/feross/cross-zip
3
+ [ci-image]: https://img.shields.io/github/workflow/status/feross/cross-zip/ci/master
4
+ [ci-url]: https://github.com/feross/cross-zip/actions
5
5
  [npm-image]: https://img.shields.io/npm/v/cross-zip.svg
6
6
  [npm-url]: https://npmjs.org/package/cross-zip
7
7
  [downloads-image]: https://img.shields.io/npm/dm/cross-zip.svg
package/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  /*! cross-zip. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
2
2
  module.exports = {
3
- zip: zip,
4
- zipSync: zipSync,
5
- unzip: unzip,
6
- unzipSync: unzipSync
3
+ zip,
4
+ zipSync,
5
+ unzip,
6
+ unzipSync
7
7
  }
8
8
 
9
- var cp = require('child_process')
10
- var fs = require('fs')
11
- var os = require('os')
12
- var path = require('path')
9
+ const cp = require('child_process')
10
+ const fs = require('fs')
11
+ const os = require('os')
12
+ const path = require('path')
13
13
 
14
14
  function zip (inPath, outPath, cb) {
15
15
  if (!cb) cb = function () {}
@@ -31,7 +31,7 @@ function zip (inPath, outPath, cb) {
31
31
  function copyToTemp () {
32
32
  fs.readFile(inPath, function (err, inFile) {
33
33
  if (err) return cb(err)
34
- var tmpPath = path.join(os.tmpdir(), 'cross-zip-' + Date.now())
34
+ const tmpPath = path.join(os.tmpdir(), 'cross-zip-' + Date.now())
35
35
  fs.mkdir(tmpPath, function (err) {
36
36
  if (err) return cb(err)
37
37
  fs.writeFile(path.join(tmpPath, path.basename(inPath)), inFile, function (err) {
@@ -53,7 +53,7 @@ function zip (inPath, outPath, cb) {
53
53
  }
54
54
 
55
55
  function doZip2 () {
56
- var opts = {
56
+ const opts = {
57
57
  cwd: path.dirname(inPath),
58
58
  maxBuffer: Infinity
59
59
  }
@@ -66,15 +66,15 @@ function zip (inPath, outPath, cb) {
66
66
  function zipSync (inPath, outPath) {
67
67
  if (process.platform === 'win32') {
68
68
  if (fs.statSync(inPath).isFile()) {
69
- var inFile = fs.readFileSync(inPath)
70
- var tmpPath = path.join(os.tmpdir(), 'cross-zip-' + Date.now())
69
+ const inFile = fs.readFileSync(inPath)
70
+ const tmpPath = path.join(os.tmpdir(), 'cross-zip-' + Date.now())
71
71
  fs.mkdirSync(tmpPath)
72
72
  fs.writeFileSync(path.join(tmpPath, path.basename(inPath)), inFile)
73
73
  inPath = tmpPath
74
74
  }
75
75
  fs.rmdirSync(outPath, { recursive: true, maxRetries: 3 })
76
76
  }
77
- var opts = {
77
+ const opts = {
78
78
  cwd: path.dirname(inPath),
79
79
  maxBuffer: Infinity
80
80
  }
@@ -83,7 +83,7 @@ function zipSync (inPath, outPath) {
83
83
 
84
84
  function unzip (inPath, outPath, cb) {
85
85
  if (!cb) cb = function () {}
86
- var opts = {
86
+ const opts = {
87
87
  maxBuffer: Infinity
88
88
  }
89
89
  cp.execFile(getUnzipCommand(), getUnzipArgs(inPath, outPath), opts, function (err) {
@@ -92,7 +92,7 @@ function unzip (inPath, outPath, cb) {
92
92
  }
93
93
 
94
94
  function unzipSync (inPath, outPath) {
95
- var opts = {
95
+ const opts = {
96
96
  maxBuffer: Infinity
97
97
  }
98
98
  cp.execFileSync(getUnzipCommand(), getUnzipArgs(inPath, outPath), opts)
@@ -128,7 +128,7 @@ function getZipArgs (inPath, outPath) {
128
128
  '-myOutPath', quotePath(outPath)
129
129
  ]
130
130
  } else {
131
- var fileName = path.basename(inPath)
131
+ const fileName = path.basename(inPath)
132
132
  return ['-r', '-y', outPath, fileName]
133
133
  }
134
134
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cross-zip",
3
3
  "description": "Cross-platform .zip file creation",
4
- "version": "4.0.0",
4
+ "version": "4.0.1",
5
5
  "author": {
6
6
  "name": "Feross Aboukhadijeh",
7
7
  "email": "feross@feross.org",
package/test/unzip.js CHANGED
@@ -1,21 +1,21 @@
1
- var fs = require('fs')
2
- var path = require('path')
3
- var test = require('tape')
4
- var zip = require('../')
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const test = require('tape')
4
+ const zip = require('../')
5
5
 
6
- var filePath = path.join(__dirname, 'content', 'file.txt')
7
- var fileZipPath = path.join(__dirname, 'content', 'file.txt.zip')
8
- var tmpPath = path.join(__dirname, 'tmp')
6
+ const filePath = path.join(__dirname, 'content', 'file.txt')
7
+ const fileZipPath = path.join(__dirname, 'content', 'file.txt.zip')
8
+ const tmpPath = path.join(__dirname, 'tmp')
9
9
 
10
10
  fs.mkdirSync(tmpPath, { recursive: true })
11
11
 
12
12
  test('unzipSync', function (t) {
13
- var tmpFilePath = path.join(tmpPath, 'file.txt')
14
- fs.rmdirSync(tmpFilePath, { recursive: true })
13
+ const tmpFilePath = path.join(tmpPath, 'file.txt')
14
+ fs.rmSync(tmpFilePath, { recursive: true, force: true })
15
15
  zip.unzipSync(fileZipPath, tmpPath)
16
16
 
17
- var tmpFile = fs.readFileSync(tmpFilePath)
18
- var file = fs.readFileSync(filePath)
17
+ const tmpFile = fs.readFileSync(tmpFilePath)
18
+ const file = fs.readFileSync(filePath)
19
19
 
20
20
  t.deepEqual(tmpFile, file)
21
21
  t.end()
@@ -24,15 +24,15 @@ test('unzipSync', function (t) {
24
24
  test('unzip', function (t) {
25
25
  t.plan(3)
26
26
 
27
- var tmpFilePath = path.join(tmpPath, 'file.txt')
28
- fs.rmdir(tmpFilePath, { recursive: true }, function (err) {
27
+ const tmpFilePath = path.join(tmpPath, 'file.txt')
28
+ fs.rm(tmpFilePath, { recursive: true }, function (err) {
29
29
  t.error(err)
30
30
 
31
31
  zip.unzip(fileZipPath, tmpPath, function (err) {
32
32
  t.error(err)
33
33
 
34
- var tmpFile = fs.readFileSync(tmpFilePath)
35
- var file = fs.readFileSync(filePath)
34
+ const tmpFile = fs.readFileSync(tmpFilePath)
35
+ const file = fs.readFileSync(filePath)
36
36
 
37
37
  t.deepEqual(tmpFile, file)
38
38
  })
@@ -42,20 +42,24 @@ test('unzip', function (t) {
42
42
  test('unzip from a folder with a space in it', function (t) {
43
43
  t.plan(4)
44
44
 
45
- var zipSpacePath = path.join(tmpPath, 'folder space', path.basename(fileZipPath))
45
+ const zipSpacePath = path.join(
46
+ tmpPath,
47
+ 'folder space',
48
+ path.basename(fileZipPath)
49
+ )
46
50
  fs.mkdirSync(path.dirname(zipSpacePath), { recursive: true })
47
51
  fs.copyFileSync(fileZipPath, zipSpacePath)
48
52
 
49
- var tmpFilePath = path.join(tmpPath, 'file.txt')
50
- fs.rmdir(tmpFilePath, { recursive: true }, function (err) {
53
+ const tmpFilePath = path.join(tmpPath, 'file.txt')
54
+ fs.rm(tmpFilePath, { recursive: true }, function (err) {
51
55
  t.error(err)
52
56
 
53
57
  zip.unzip(zipSpacePath, tmpPath, function (err) {
54
58
  t.error(err)
55
59
 
56
60
  t.ok(fs.existsSync(tmpFilePath), 'extracted file should exist')
57
- var tmpFile = fs.readFileSync(tmpFilePath)
58
- var file = fs.readFileSync(filePath)
61
+ const tmpFile = fs.readFileSync(tmpFilePath)
62
+ const file = fs.readFileSync(filePath)
59
63
 
60
64
  t.deepEqual(tmpFile, file)
61
65
  })
package/test/zip.js CHANGED
@@ -1,23 +1,23 @@
1
- var fs = require('fs')
2
- var path = require('path')
3
- var test = require('tape')
4
- var zip = require('../')
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const test = require('tape')
4
+ const zip = require('../')
5
5
 
6
- var filePath = path.join(__dirname, 'content', 'file.txt')
7
- var tmpPath = path.join(__dirname, 'tmp')
6
+ const filePath = path.join(__dirname, 'content', 'file.txt')
7
+ const tmpPath = path.join(__dirname, 'tmp')
8
8
 
9
9
  fs.mkdirSync(tmpPath, { recursive: true })
10
10
 
11
11
  test('zipSync', function (t) {
12
- var tmpFileZipPath = path.join(tmpPath, 'file.zip')
12
+ const tmpFileZipPath = path.join(tmpPath, 'file.zip')
13
13
  zip.zipSync(filePath, tmpFileZipPath)
14
14
 
15
- var tmpFilePath = path.join(tmpPath, 'file.txt')
16
- fs.rmdirSync(tmpFilePath, { recursive: true })
15
+ const tmpFilePath = path.join(tmpPath, 'file.txt')
16
+ fs.rmSync(tmpFilePath, { recursive: true, force: true })
17
17
  zip.unzipSync(tmpFileZipPath, tmpPath)
18
18
 
19
- var tmpFile = fs.readFileSync(tmpFilePath)
20
- var file = fs.readFileSync(filePath)
19
+ const tmpFile = fs.readFileSync(tmpFilePath)
20
+ const file = fs.readFileSync(filePath)
21
21
 
22
22
  t.deepEqual(tmpFile, file)
23
23
  t.end()
@@ -26,19 +26,19 @@ test('zipSync', function (t) {
26
26
  test('zip', function (t) {
27
27
  t.plan(4)
28
28
 
29
- var tmpFileZipPath = path.join(tmpPath, 'file.zip')
29
+ const tmpFileZipPath = path.join(tmpPath, 'file.zip')
30
30
  zip.zip(filePath, tmpFileZipPath, function (err) {
31
31
  t.error(err)
32
32
 
33
- var tmpFilePath = path.join(tmpPath, 'file.txt')
34
- fs.rmdir(tmpFilePath, { recursive: true }, function (err) {
33
+ const tmpFilePath = path.join(tmpPath, 'file.txt')
34
+ fs.rm(tmpFilePath, { recursive: true }, function (err) {
35
35
  t.error(err)
36
36
 
37
37
  zip.unzip(tmpFileZipPath, tmpPath, function (err) {
38
38
  t.error(err)
39
39
 
40
- var tmpFile = fs.readFileSync(tmpFilePath)
41
- var file = fs.readFileSync(filePath)
40
+ const tmpFile = fs.readFileSync(tmpFilePath)
41
+ const file = fs.readFileSync(filePath)
42
42
 
43
43
  t.deepEqual(tmpFile, file)
44
44
  })
package/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - lts/*
4
- os:
5
- - linux
6
- - osx
7
- - windows
8
- git:
9
- autocrlf: input