cross-zip 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
package/.travis.yml CHANGED
@@ -1,3 +1,9 @@
1
1
  language: node_js
2
2
  node_js:
3
3
  - lts/*
4
+ os:
5
+ - linux
6
+ - osx
7
+ - windows
8
+ git:
9
+ autocrlf: input
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ /*! cross-zip. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
1
2
  module.exports = {
2
3
  zip: zip,
3
4
  zipSync: zipSync,
@@ -114,14 +115,18 @@ function getUnzipCommand () {
114
115
  }
115
116
  }
116
117
 
118
+ function quotePath (pathToTransform) {
119
+ return '"' + pathToTransform + '"'
120
+ }
121
+
117
122
  function getZipArgs (inPath, outPath) {
118
123
  if (process.platform === 'win32') {
119
124
  return [
120
125
  '-nologo',
121
126
  '-noprofile',
122
- '-command', '& { param([String]$myInPath, [String]$myOutPath); Add-Type -A "System.IO.Compression.FileSystem"; [IO.Compression.ZipFile]::CreateFromDirectory($myInPath, $myOutPath); }',
123
- '-myInPath', inPath,
124
- '-myOutPath', outPath
127
+ '-command', '& { param([String]$myInPath, [String]$myOutPath); Add-Type -A "System.IO.Compression.FileSystem"; [IO.Compression.ZipFile]::CreateFromDirectory($myInPath, $myOutPath); exit !$? }',
128
+ '-myInPath', quotePath(inPath),
129
+ '-myOutPath', quotePath(outPath)
125
130
  ]
126
131
  } else {
127
132
  var fileName = path.basename(inPath)
@@ -134,9 +139,9 @@ function getUnzipArgs (inPath, outPath) {
134
139
  return [
135
140
  '-nologo',
136
141
  '-noprofile',
137
- '-command', '& { param([String]$myInPath, [String]$myOutPath); Add-Type -A "System.IO.Compression.FileSystem"; [IO.Compression.ZipFile]::ExtractToDirectory($myInPath, $myOutPath); }',
138
- '-myInPath', inPath,
139
- '-myOutPath', outPath
142
+ '-command', '& { param([String]$myInPath, [String]$myOutPath); Add-Type -A "System.IO.Compression.FileSystem"; [IO.Compression.ZipFile]::ExtractToDirectory($myInPath, $myOutPath); exit !$? }',
143
+ '-myInPath', quotePath(inPath),
144
+ '-myOutPath', quotePath(outPath)
140
145
  ]
141
146
  } else {
142
147
  return ['-o', inPath, '-d', outPath]
package/package.json CHANGED
@@ -1,19 +1,18 @@
1
1
  {
2
2
  "name": "cross-zip",
3
3
  "description": "Cross-platform .zip file creation",
4
- "version": "3.0.0",
4
+ "version": "3.1.0",
5
5
  "author": {
6
6
  "name": "Feross Aboukhadijeh",
7
7
  "email": "feross@feross.org",
8
- "url": "http://feross.org/"
8
+ "url": "https://feross.org"
9
9
  },
10
10
  "bugs": {
11
11
  "url": "https://github.com/feross/cross-zip/issues"
12
12
  },
13
13
  "devDependencies": {
14
- "mkdirp": "^0.5.1",
15
14
  "standard": "*",
16
- "tape": "^4.0.0"
15
+ "tape": "^5.0.0"
17
16
  },
18
17
  "homepage": "https://github.com/feross/cross-zip",
19
18
  "keywords": [
@@ -37,5 +36,19 @@
37
36
  },
38
37
  "dependencies": {
39
38
  "rimraf": "^3.0.0"
40
- }
39
+ },
40
+ "funding": [
41
+ {
42
+ "type": "github",
43
+ "url": "https://github.com/sponsors/feross"
44
+ },
45
+ {
46
+ "type": "patreon",
47
+ "url": "https://www.patreon.com/feross"
48
+ },
49
+ {
50
+ "type": "consulting",
51
+ "url": "https://feross.org/support"
52
+ }
53
+ ]
41
54
  }
package/test/unzip.js CHANGED
@@ -1,5 +1,4 @@
1
1
  var fs = require('fs')
2
- var mkdirp = require('mkdirp')
3
2
  var path = require('path')
4
3
  var rimraf = require('rimraf')
5
4
  var test = require('tape')
@@ -9,7 +8,7 @@ var filePath = path.join(__dirname, 'content', 'file.txt')
9
8
  var fileZipPath = path.join(__dirname, 'content', 'file.txt.zip')
10
9
  var tmpPath = path.join(__dirname, 'tmp')
11
10
 
12
- mkdirp.sync(tmpPath)
11
+ fs.mkdirSync(tmpPath, { recursive: true })
13
12
 
14
13
  test('unzipSync', function (t) {
15
14
  var tmpFilePath = path.join(tmpPath, 'file.txt')
@@ -40,3 +39,26 @@ test('unzip', function (t) {
40
39
  })
41
40
  })
42
41
  })
42
+
43
+ test('unzip from a folder with a space in it', function (t) {
44
+ t.plan(4)
45
+
46
+ var zipSpacePath = path.join(tmpPath, 'folder space', path.basename(fileZipPath))
47
+ fs.mkdirSync(path.dirname(zipSpacePath), { recursive: true })
48
+ fs.copyFileSync(fileZipPath, zipSpacePath)
49
+
50
+ var tmpFilePath = path.join(tmpPath, 'file.txt')
51
+ rimraf(tmpFilePath, function (err) {
52
+ t.error(err)
53
+
54
+ zip.unzip(zipSpacePath, tmpPath, function (err) {
55
+ t.error(err)
56
+
57
+ t.ok(fs.existsSync(tmpFilePath), 'extracted file should exist')
58
+ var tmpFile = fs.readFileSync(tmpFilePath)
59
+ var file = fs.readFileSync(filePath)
60
+
61
+ t.deepEqual(tmpFile, file)
62
+ })
63
+ })
64
+ })
package/test/zip.js CHANGED
@@ -1,5 +1,4 @@
1
1
  var fs = require('fs')
2
- var mkdirp = require('mkdirp')
3
2
  var path = require('path')
4
3
  var rimraf = require('rimraf')
5
4
  var test = require('tape')
@@ -8,7 +7,7 @@ var zip = require('../')
8
7
  var filePath = path.join(__dirname, 'content', 'file.txt')
9
8
  var tmpPath = path.join(__dirname, 'tmp')
10
9
 
11
- mkdirp.sync(tmpPath)
10
+ fs.mkdirSync(tmpPath, { recursive: true })
12
11
 
13
12
  test('zipSync', function (t) {
14
13
  var tmpFileZipPath = path.join(tmpPath, 'file.zip')