cross-zip 3.1.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,16 +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')
13
- var rimraf = require('rimraf')
9
+ const cp = require('child_process')
10
+ const fs = require('fs')
11
+ const os = require('os')
12
+ const path = require('path')
14
13
 
15
14
  function zip (inPath, outPath, cb) {
16
15
  if (!cb) cb = function () {}
@@ -32,7 +31,7 @@ function zip (inPath, outPath, cb) {
32
31
  function copyToTemp () {
33
32
  fs.readFile(inPath, function (err, inFile) {
34
33
  if (err) return cb(err)
35
- var tmpPath = path.join(os.tmpdir(), 'cross-zip-' + Date.now())
34
+ const tmpPath = path.join(os.tmpdir(), 'cross-zip-' + Date.now())
36
35
  fs.mkdir(tmpPath, function (err) {
37
36
  if (err) return cb(err)
38
37
  fs.writeFile(path.join(tmpPath, path.basename(inPath)), inFile, function (err) {
@@ -47,14 +46,14 @@ function zip (inPath, outPath, cb) {
47
46
  // Windows zip command does not overwrite existing files. So do it manually first.
48
47
  function doZip () {
49
48
  if (process.platform === 'win32') {
50
- rimraf(outPath, doZip2)
49
+ fs.rmdir(outPath, { recursive: true, maxRetries: 3 }, doZip2)
51
50
  } else {
52
51
  doZip2()
53
52
  }
54
53
  }
55
54
 
56
55
  function doZip2 () {
57
- var opts = {
56
+ const opts = {
58
57
  cwd: path.dirname(inPath),
59
58
  maxBuffer: Infinity
60
59
  }
@@ -67,15 +66,15 @@ function zip (inPath, outPath, cb) {
67
66
  function zipSync (inPath, outPath) {
68
67
  if (process.platform === 'win32') {
69
68
  if (fs.statSync(inPath).isFile()) {
70
- var inFile = fs.readFileSync(inPath)
71
- 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())
72
71
  fs.mkdirSync(tmpPath)
73
72
  fs.writeFileSync(path.join(tmpPath, path.basename(inPath)), inFile)
74
73
  inPath = tmpPath
75
74
  }
76
- rimraf.sync(outPath)
75
+ fs.rmdirSync(outPath, { recursive: true, maxRetries: 3 })
77
76
  }
78
- var opts = {
77
+ const opts = {
79
78
  cwd: path.dirname(inPath),
80
79
  maxBuffer: Infinity
81
80
  }
@@ -84,7 +83,7 @@ function zipSync (inPath, outPath) {
84
83
 
85
84
  function unzip (inPath, outPath, cb) {
86
85
  if (!cb) cb = function () {}
87
- var opts = {
86
+ const opts = {
88
87
  maxBuffer: Infinity
89
88
  }
90
89
  cp.execFile(getUnzipCommand(), getUnzipArgs(inPath, outPath), opts, function (err) {
@@ -93,7 +92,7 @@ function unzip (inPath, outPath, cb) {
93
92
  }
94
93
 
95
94
  function unzipSync (inPath, outPath) {
96
- var opts = {
95
+ const opts = {
97
96
  maxBuffer: Infinity
98
97
  }
99
98
  cp.execFileSync(getUnzipCommand(), getUnzipArgs(inPath, outPath), opts)
@@ -129,7 +128,7 @@ function getZipArgs (inPath, outPath) {
129
128
  '-myOutPath', quotePath(outPath)
130
129
  ]
131
130
  } else {
132
- var fileName = path.basename(inPath)
131
+ const fileName = path.basename(inPath)
133
132
  return ['-r', '-y', outPath, fileName]
134
133
  }
135
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": "3.1.0",
4
+ "version": "4.0.1",
5
5
  "author": {
6
6
  "name": "Feross Aboukhadijeh",
7
7
  "email": "feross@feross.org",
@@ -34,8 +34,8 @@
34
34
  "scripts": {
35
35
  "test": "standard && tape test/*.js"
36
36
  },
37
- "dependencies": {
38
- "rimraf": "^3.0.0"
37
+ "engines": {
38
+ "node": ">=12.10"
39
39
  },
40
40
  "funding": [
41
41
  {
package/test/unzip.js CHANGED
@@ -1,22 +1,21 @@
1
- var fs = require('fs')
2
- var path = require('path')
3
- var rimraf = require('rimraf')
4
- var test = require('tape')
5
- var zip = require('../')
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const test = require('tape')
4
+ const zip = require('../')
6
5
 
7
- var filePath = path.join(__dirname, 'content', 'file.txt')
8
- var fileZipPath = path.join(__dirname, 'content', 'file.txt.zip')
9
- 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')
10
9
 
11
10
  fs.mkdirSync(tmpPath, { recursive: true })
12
11
 
13
12
  test('unzipSync', function (t) {
14
- var tmpFilePath = path.join(tmpPath, 'file.txt')
15
- rimraf.sync(tmpFilePath)
13
+ const tmpFilePath = path.join(tmpPath, 'file.txt')
14
+ fs.rmSync(tmpFilePath, { recursive: true, force: true })
16
15
  zip.unzipSync(fileZipPath, tmpPath)
17
16
 
18
- var tmpFile = fs.readFileSync(tmpFilePath)
19
- var file = fs.readFileSync(filePath)
17
+ const tmpFile = fs.readFileSync(tmpFilePath)
18
+ const file = fs.readFileSync(filePath)
20
19
 
21
20
  t.deepEqual(tmpFile, file)
22
21
  t.end()
@@ -25,15 +24,15 @@ test('unzipSync', function (t) {
25
24
  test('unzip', function (t) {
26
25
  t.plan(3)
27
26
 
28
- var tmpFilePath = path.join(tmpPath, 'file.txt')
29
- rimraf(tmpFilePath, function (err) {
27
+ const tmpFilePath = path.join(tmpPath, 'file.txt')
28
+ fs.rm(tmpFilePath, { recursive: true }, function (err) {
30
29
  t.error(err)
31
30
 
32
31
  zip.unzip(fileZipPath, tmpPath, function (err) {
33
32
  t.error(err)
34
33
 
35
- var tmpFile = fs.readFileSync(tmpFilePath)
36
- var file = fs.readFileSync(filePath)
34
+ const tmpFile = fs.readFileSync(tmpFilePath)
35
+ const file = fs.readFileSync(filePath)
37
36
 
38
37
  t.deepEqual(tmpFile, file)
39
38
  })
@@ -43,20 +42,24 @@ test('unzip', function (t) {
43
42
  test('unzip from a folder with a space in it', function (t) {
44
43
  t.plan(4)
45
44
 
46
- 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
+ )
47
50
  fs.mkdirSync(path.dirname(zipSpacePath), { recursive: true })
48
51
  fs.copyFileSync(fileZipPath, zipSpacePath)
49
52
 
50
- var tmpFilePath = path.join(tmpPath, 'file.txt')
51
- rimraf(tmpFilePath, function (err) {
53
+ const tmpFilePath = path.join(tmpPath, 'file.txt')
54
+ fs.rm(tmpFilePath, { recursive: true }, function (err) {
52
55
  t.error(err)
53
56
 
54
57
  zip.unzip(zipSpacePath, tmpPath, function (err) {
55
58
  t.error(err)
56
59
 
57
60
  t.ok(fs.existsSync(tmpFilePath), 'extracted file should exist')
58
- var tmpFile = fs.readFileSync(tmpFilePath)
59
- var file = fs.readFileSync(filePath)
61
+ const tmpFile = fs.readFileSync(tmpFilePath)
62
+ const file = fs.readFileSync(filePath)
60
63
 
61
64
  t.deepEqual(tmpFile, file)
62
65
  })
package/test/zip.js CHANGED
@@ -1,24 +1,23 @@
1
- var fs = require('fs')
2
- var path = require('path')
3
- var rimraf = require('rimraf')
4
- var test = require('tape')
5
- var zip = require('../')
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const test = require('tape')
4
+ const zip = require('../')
6
5
 
7
- var filePath = path.join(__dirname, 'content', 'file.txt')
8
- var tmpPath = path.join(__dirname, 'tmp')
6
+ const filePath = path.join(__dirname, 'content', 'file.txt')
7
+ const tmpPath = path.join(__dirname, 'tmp')
9
8
 
10
9
  fs.mkdirSync(tmpPath, { recursive: true })
11
10
 
12
11
  test('zipSync', function (t) {
13
- var tmpFileZipPath = path.join(tmpPath, 'file.zip')
12
+ const tmpFileZipPath = path.join(tmpPath, 'file.zip')
14
13
  zip.zipSync(filePath, tmpFileZipPath)
15
14
 
16
- var tmpFilePath = path.join(tmpPath, 'file.txt')
17
- rimraf.sync(tmpFilePath)
15
+ const tmpFilePath = path.join(tmpPath, 'file.txt')
16
+ fs.rmSync(tmpFilePath, { recursive: true, force: true })
18
17
  zip.unzipSync(tmpFileZipPath, tmpPath)
19
18
 
20
- var tmpFile = fs.readFileSync(tmpFilePath)
21
- var file = fs.readFileSync(filePath)
19
+ const tmpFile = fs.readFileSync(tmpFilePath)
20
+ const file = fs.readFileSync(filePath)
22
21
 
23
22
  t.deepEqual(tmpFile, file)
24
23
  t.end()
@@ -27,19 +26,19 @@ test('zipSync', function (t) {
27
26
  test('zip', function (t) {
28
27
  t.plan(4)
29
28
 
30
- var tmpFileZipPath = path.join(tmpPath, 'file.zip')
29
+ const tmpFileZipPath = path.join(tmpPath, 'file.zip')
31
30
  zip.zip(filePath, tmpFileZipPath, function (err) {
32
31
  t.error(err)
33
32
 
34
- var tmpFilePath = path.join(tmpPath, 'file.txt')
35
- rimraf(tmpFilePath, function (err) {
33
+ const tmpFilePath = path.join(tmpPath, 'file.txt')
34
+ fs.rm(tmpFilePath, { recursive: true }, function (err) {
36
35
  t.error(err)
37
36
 
38
37
  zip.unzip(tmpFileZipPath, tmpPath, function (err) {
39
38
  t.error(err)
40
39
 
41
- var tmpFile = fs.readFileSync(tmpFilePath)
42
- var file = fs.readFileSync(filePath)
40
+ const tmpFile = fs.readFileSync(tmpFilePath)
41
+ const file = fs.readFileSync(filePath)
43
42
 
44
43
  t.deepEqual(tmpFile, file)
45
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