Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asar

Package Overview
Dependencies
Maintainers
5
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asar - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

test/expected/packthis-unpack-dir.asar

11

lib/asar.js

@@ -35,3 +35,3 @@ (function() {

}, function(error, filenames, metadata) {
var file, filename, files, filesystem, shouldUnpack, _i, _len;
var dirName, file, filename, files, filesystem, shouldUnpack, _i, _len;
if (error) {

@@ -47,3 +47,6 @@ return callback(error);

case 'directory':
filesystem.insertDirectory(filename);
shouldUnpack = options.unpackDir ? minimatch(path.basename(filename), options.unpackDir, {
matchBase: true
}) : false;
filesystem.insertDirectory(filename, shouldUnpack);
break;

@@ -53,3 +56,5 @@ case 'file':

matchBase: true
}) : false;
}) : options.unpackDir ? (dirName = path.relative(src, path.dirname(filename)), minimatch(dirName, options.unpackDir, {
matchBase: true
})) : false;
files.push({

@@ -56,0 +61,0 @@ filename: filename,

@@ -35,10 +35,19 @@ (function() {

p = path.relative(this.src, p);
if (!p) {
return this.header;
}
name = path.basename(p);
node = this.searchNodeFromDirectory(path.dirname(p)).files[name] = {};
return node;
node = this.searchNodeFromDirectory(path.dirname(p));
if (!node.files[name]) {
node.files[name] = {};
}
return node.files[name];
};
Filesystem.prototype.insertDirectory = function(p) {
Filesystem.prototype.insertDirectory = function(p, shouldUnpack) {
var node;
node = this.searchNodeFromPath(p);
if (shouldUnpack) {
node.unpacked = shouldUnpack;
}
return node.files = {};

@@ -48,5 +57,6 @@ };

Filesystem.prototype.insertFile = function(p, shouldUnpack, stat) {
var node;
var dirNode, node;
dirNode = this.searchNodeFromPath(path.dirname(p));
node = this.searchNodeFromPath(p);
if (shouldUnpack) {
if (shouldUnpack || dirNode.unpacked) {
node.size = stat.size;

@@ -53,0 +63,0 @@ node.unpacked = true;

@@ -5,3 +5,3 @@ {

"description": "Creating atom-shell app packages",
"version": "0.8.0",
"version": "0.8.1",
"bin": {

@@ -8,0 +8,0 @@ "asar": "bin/asar"

@@ -67,5 +67,16 @@ 'use strict';

asar.extractAll('test/input/extractthis-unpack.asar','tmp/extractthis-unpack-api/');
compDirs('tmp/extractthis-api/', 'test/expected/extractthis', done);
compDirs('tmp/extractthis-unpack-api/', 'test/expected/extractthis', done);
});
it('should extract a binary file from archive with unpacked files', function() {
var actual = asar.extractFile('test/input/extractthis-unpack-dir.asar', 'dir1/file1.txt');
var expected = fs.readFileSync('test/expected/extractthis/dir1/file1.txt', 'utf8');
return assert.equal(actual, expected);
});
it('should extract an archive with unpacked dirs', function(done) {
asar.extractAll('test/input/extractthis-unpack-dir.asar','tmp/extractthis-unpack-dir-api/');
compDirs('tmp/extractthis-unpack-dir-api/', 'test/expected/extractthis', done);
});
});

@@ -93,2 +93,27 @@ 'use strict';

it('should create archive from directory with unpacked dirs', function(done) {
exec('node bin/asar p test/input/packthis/ tmp/packthis-unpack-dir-cli.asar --unpack-dir dir2 --exclude-hidden', function (error, stdout, stderr) {
var actual = fs.readFileSync('tmp/packthis-unpack-dir-cli.asar', 'utf8');
var expected = fs.readFileSync('test/expected/packthis-unpack-dir.asar', 'utf8');
done(assert.equal(actual, expected));
});
});
it('should list files/dirs in archive with unpacked dirs', function(done) {
exec('node bin/asar l tmp/packthis-unpack-dir-cli.asar', function (error, stdout, stderr) {
var actual = stdout;
var expected = fs.readFileSync('test/expected/extractthis-filelist.txt', 'utf8') + '\n';
// on windows replace slashes with backslashes and crlf with lf
if ('win32' === os.platform())
expected = expected.replace(/\//g, '\\').replace(/\r\n/g, '\n');
done(assert.equal(actual, expected));
});
});
it('should extract an archive with unpacked dirs', function(done) {
exec('node bin/asar e test/input/extractthis-unpack-dir.asar tmp/extractthis-unpack-dir/', function (error, stdout, stderr) {
compDirs('tmp/extractthis-unpack-dir/', 'test/expected/extractthis', done);
});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc