Comparing version 0.9.0 to 0.9.1
(function() { | ||
var Filesystem, crawlFilesystem, createSnapshot, disk, fs, minimatch, mkdirp, os, path, startWith; | ||
var Filesystem, crawlFilesystem, createSnapshot, disk, fs, isUnpackDir, minimatch, mkdirp, os, path; | ||
@@ -22,4 +22,4 @@ fs = require('fs'); | ||
startWith = function(path, prefix) { | ||
return path.indexOf(prefix) === 0; | ||
isUnpackDir = function(path, pattern) { | ||
return path.indexOf(pattern) === 0 || minimatch(path, pattern); | ||
}; | ||
@@ -93,3 +93,3 @@ | ||
case 'directory': | ||
shouldUnpack = options.unpackDir ? startWith(path.relative(src, filename), options.unpackDir) : false; | ||
shouldUnpack = options.unpackDir ? isUnpackDir(path.relative(src, filename), options.unpackDir) : false; | ||
filesystem.insertDirectory(filename, shouldUnpack); | ||
@@ -106,3 +106,3 @@ break; | ||
dirName = path.relative(src, path.dirname(filename)); | ||
shouldUnpack = startWith(dirName, options.unpackDir); | ||
shouldUnpack = isUnpackDir(dirName, options.unpackDir); | ||
} | ||
@@ -109,0 +109,0 @@ files.push({ |
@@ -5,3 +5,3 @@ { | ||
"description": "Creating atom-shell app packages", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"bin": { | ||
@@ -8,0 +8,0 @@ "asar": "bin/asar" |
@@ -53,2 +53,32 @@ # asar - Atom-Shell Archive | ||
#### Excluding multiple resources from being packed | ||
Given: | ||
``` | ||
app | ||
(a) ├── x1 | ||
(b) ├── x2 | ||
(c) ├── y3 | ||
(d) │ ├── x1 | ||
(e) │ └── z1 | ||
(f) │ └── x2 | ||
(g) └── z4 | ||
(h) └── w1 | ||
``` | ||
Exclude: a, b | ||
```bash | ||
$ asar pack app app.asar --unpack-dir "{x1,x2}" | ||
``` | ||
Exclude: a, b, d, f | ||
```bash | ||
$ asar pack app app.asar --unpack-dir "**/{x1,x2}" | ||
``` | ||
Exclude: a, b, d, f, h | ||
```bash | ||
$ asar pack app app.asar --unpack-dir "{**/x1,**/x2,z4/w1}" | ||
``` | ||
## Using programatically | ||
@@ -55,0 +85,0 @@ |
@@ -104,2 +104,28 @@ 'use strict'; | ||
it('should create archive from directory with unpacked dirs specified by glob pattern', function(done) { | ||
var tmpFile = 'tmp/packthis-unpack-dir-glob-cli.asar'; | ||
var tmpUnpacked = 'tmp/packthis-unpack-dir-glob-cli.asar.unpacked'; | ||
exec('node bin/asar p test/input/packthis-glob/ ' + tmpFile + ' --unpack-dir "{x1,x2}" --exclude-hidden', function (error, stdout, stderr) { | ||
var actual = fs.readFileSync(tmpFile, 'utf8'); | ||
var expected = fs.readFileSync('test/expected/packthis-unpack-dir-glob.asar', 'utf8'); | ||
assert.ok(fs.existsSync(tmpUnpacked + '/x1/file1.txt')); | ||
assert.ok(fs.existsSync(tmpUnpacked + '/x2/file2.txt')); | ||
done(assert.equal(actual, expected)); | ||
}); | ||
}); | ||
it('should create archive from directory with unpacked dirs specified by globstar pattern', function(done) { | ||
var tmpFile = 'tmp/packthis-unpack-dir-globstar-cli.asar'; | ||
var tmpUnpacked = 'tmp/packthis-unpack-dir-globstar-cli.asar.unpacked'; | ||
exec('node bin/asar p test/input/packthis-glob/ ' + tmpFile + ' --unpack-dir "**/{x1,x2}" --exclude-hidden', function (error, stdout, stderr) { | ||
var actual = fs.readFileSync(tmpFile, 'utf8'); | ||
var expected = fs.readFileSync('test/expected/packthis-unpack-dir-globstar.asar', 'utf8'); | ||
assert.ok(fs.existsSync(tmpUnpacked + '/x1/file1.txt')); | ||
assert.ok(fs.existsSync(tmpUnpacked + '/x2/file2.txt')); | ||
assert.ok(fs.existsSync(tmpUnpacked + '/y3/x1/file4.txt')); | ||
assert.ok(fs.existsSync(tmpUnpacked + '/y3/z1/x2/file5.txt')); | ||
done(assert.equal(actual, expected)); | ||
}); | ||
}); | ||
it('should list files/dirs in archive with unpacked dirs', function(done) { | ||
@@ -106,0 +132,0 @@ exec('node bin/asar l tmp/packthis-unpack-dir-cli.asar', function (error, stdout, stderr) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45604
49
785
173