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.
- package/.github/dependabot.yml +15 -0
- package/.github/workflows/ci.yml +23 -0
- package/README.md +3 -3
- package/index.js +16 -16
- package/package.json +1 -1
- package/test/unzip.js +24 -20
- package/test/zip.js +16 -16
- package/.travis.yml +0 -9
@@ -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 [![
|
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
|
-
[
|
4
|
-
[
|
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
|
4
|
-
zipSync
|
5
|
-
unzip
|
6
|
-
unzipSync
|
3
|
+
zip,
|
4
|
+
zipSync,
|
5
|
+
unzip,
|
6
|
+
unzipSync
|
7
7
|
}
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
70
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
131
|
+
const fileName = path.basename(inPath)
|
132
132
|
return ['-r', '-y', outPath, fileName]
|
133
133
|
}
|
134
134
|
}
|
package/package.json
CHANGED
package/test/unzip.js
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
const fs = require('fs')
|
2
|
+
const path = require('path')
|
3
|
+
const test = require('tape')
|
4
|
+
const zip = require('../')
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
14
|
-
fs.
|
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
|
-
|
18
|
-
|
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
|
-
|
28
|
-
fs.
|
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
|
-
|
35
|
-
|
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
|
-
|
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
|
-
|
50
|
-
fs.
|
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
|
-
|
58
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
const fs = require('fs')
|
2
|
+
const path = require('path')
|
3
|
+
const test = require('tape')
|
4
|
+
const zip = require('../')
|
5
5
|
|
6
|
-
|
7
|
-
|
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
|
-
|
12
|
+
const tmpFileZipPath = path.join(tmpPath, 'file.zip')
|
13
13
|
zip.zipSync(filePath, tmpFileZipPath)
|
14
14
|
|
15
|
-
|
16
|
-
fs.
|
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
|
-
|
20
|
-
|
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
|
-
|
29
|
+
const tmpFileZipPath = path.join(tmpPath, 'file.zip')
|
30
30
|
zip.zip(filePath, tmpFileZipPath, function (err) {
|
31
31
|
t.error(err)
|
32
32
|
|
33
|
-
|
34
|
-
fs.
|
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
|
-
|
41
|
-
|
40
|
+
const tmpFile = fs.readFileSync(tmpFilePath)
|
41
|
+
const file = fs.readFileSync(filePath)
|
42
42
|
|
43
43
|
t.deepEqual(tmpFile, file)
|
44
44
|
})
|