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

scratch-parser

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scratch-parser - npm Package Compare versions

Comparing version 4.3.3 to 4.3.4

test/fixtures/data/_bananas_nested.sprite2

16

lib/unzip.js

@@ -26,6 +26,14 @@ var JSZip = require('jszip');

.then(function (zip) {
return zip.file(isSprite ? 'sprite.json' : 'project.json').async('string')
.then(function (project) {
return callback(null, [project, zip]);
});
// look for json in the list of files, or in a subdirectory
// assumes there is only one sprite or project json in the zipfile
const file = isSprite ?
zip.file(/^([^/]*\/)?sprite\.json$/)[0] :
zip.file(/^([^/]*\/)?project\.json$/)[0];
if (file) {
return file.async('string')
.then(function (project) {
return callback(null, [project, zip]);
});
}
return callback(msg + 'missing project or sprite json');
})

@@ -32,0 +40,0 @@ .catch(function (err) {

@@ -50,3 +50,3 @@ {

},
"version": "4.3.3"
"version": "4.3.4"
}

@@ -36,3 +36,4 @@ var fs = require('fs');

json: fs.readFileSync(path.resolve(__dirname, './data/_example.json')),
gzipJson: fs.readFileSync(path.resolve(__dirname, './data/_example.json.gz'))
gzipJson: fs.readFileSync(path.resolve(__dirname, './data/_example.json.gz')),
invalidEmpty: fs.readFileSync(path.resolve(__dirname, './data/invalid/_invalidEmpty.sb2'))
},

@@ -44,3 +45,4 @@ sprites: {

example_sprite2_json: fs.readFileSync(path.resolve(__dirname, './data/_example_sprite.sprite2json')),
bananas_sprite2: fs.readFileSync(path.resolve(__dirname, './data/_bananas.sprite2'))
bananas_sprite2: fs.readFileSync(path.resolve(__dirname, './data/_bananas.sprite2')),
bananas_nested_sprite2: fs.readFileSync(path.resolve(__dirname, './data/_bananas_nested.sprite2'))
},

@@ -47,0 +49,0 @@ sb3_comments: {

@@ -65,1 +65,11 @@ var test = require('tap').test;

});
test('invalid empty project archive', function (t) {
var msg = 'Failed to unzip and extract project.json, with error: ';
parser(data.example.invalidEmpty, false, function (err, result) {
t.type(err, 'string');
t.equal(err.startsWith(msg), true);
t.type(result, 'undefined');
t.end();
});
});

@@ -45,2 +45,15 @@ var test = require('tap').test;

test('nested banana sprite2', function (t) {
parser(data.sprites.bananas_nested_sprite2, true, function (err, result) {
t.equal(err, null);
t.equal(Array.isArray(result), true);
var res = result[0];
var possibleZip = result[1];
t.type(res, 'object');
t.equal(res.projectVersion, 2);
t.equal(possibleZip instanceof JSZip, true);
t.end();
});
});
test('default cat sprite2 json', function (t) {

@@ -47,0 +60,0 @@ parser(data.sprites.default_cat_sprite2_json, true, function (err, result) {

@@ -14,3 +14,4 @@ var fs = require('fs');

zipNoProjectJSON:
path.resolve(__dirname, '../fixtures/data/_zipNoProjectJson.zip')
path.resolve(__dirname, '../fixtures/data/_zipNoProjectJson.zip'),
sb2Nested: path.resolve(__dirname, '../fixtures/data/_nestedFolder.sb2')
};

@@ -67,2 +68,16 @@

test('sb2 with nested folder', function (t) {
var buffer = new Buffer(fixtures.sb2Nested);
unzip(buffer, false, false, function (err, res) {
t.equal(err, null);
t.equal(Array.isArray(res), true);
t.type(res[0], 'string');
t.doesNotThrow(function () {
JSON.parse(res[0]);
});
t.equal(res[1] instanceof JSZip, true);
t.end();
});
});
test('zip without project json', function (t) {

@@ -69,0 +84,0 @@ var buffer = new Buffer(fixtures.zipNoProjectJSON);

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