Comparing version 0.3.4 to 0.3.5
# Changelog | ||
## 0.3.5 | ||
* Download and extract dmg image on Mac. | ||
## 0.3.4 | ||
@@ -27,15 +31,20 @@ | ||
## 0.2.15 | ||
## 0.2.22 | ||
* Bump nan, fixes build on io.js 2.0.2 | ||
* Download and extract dmg image on Mac. | ||
## 0.2.16 | ||
## 0.2.21 | ||
* Bump nan, fix resulting build issues -> io.js 3.2 support | ||
* Download libxl via HTTPS. | ||
## 0.2.17 | ||
## 0.2.20 | ||
* Bump npm dependency versions. | ||
* Migrate from MD5 to md5. | ||
* Download libxl via HTTP instead of FTP. | ||
## 0.2.19 | ||
* Allow formats belonging to a different book as templates for addFormat (see | ||
[issue #10](https://github.com/DirtyHairy/node-libxl/issues/10)). | ||
* Bump dependency versions. | ||
## 0.2.18 | ||
@@ -46,6 +55,13 @@ | ||
## 0.2.19 | ||
## 0.2.17 | ||
* Allow formats belonging to a different book as templates for addFormat (see | ||
[issue #10](https://github.com/DirtyHairy/node-libxl/issues/10)). | ||
* Bump dependency versions. | ||
* Bump npm dependency versions. | ||
* Migrate from MD5 to md5. | ||
## 0.2.16 | ||
* Bump nan, fix resulting build issues -> io.js 3.2 support | ||
## 0.2.15 | ||
* Bump nan, fixes build on io.js 2.0.2 |
/** | ||
* The MIT License (MIT) | ||
* | ||
* | ||
* Copyright (c) 2013 Christian Speckner <cnspeckn@googlemail.com>, | ||
* Torben Fitschen <teddyttn@gmail.com> | ||
* | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
@@ -13,6 +13,6 @@ * of this software and associated documentation files (the "Software"), to deal | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
@@ -28,2 +28,3 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
var fs = require('fs'), | ||
childProcess = require('child_process'), | ||
os = require('os'), | ||
@@ -36,2 +37,3 @@ path = require('path'), | ||
tar = require('tar'), | ||
plist = require('plist'), | ||
https = require('https'), | ||
@@ -46,3 +48,3 @@ AdmZip = require('adm-zip'); | ||
var download = function(callback) { | ||
function download(callback) { | ||
function getPlaform() { | ||
@@ -60,4 +62,17 @@ if (isWin) { | ||
function getArchiveSuffix() { | ||
switch (getPlaform()) { | ||
case 'win': | ||
return 'zip'; | ||
case 'mac': | ||
return 'dmg'; | ||
default: | ||
return 'tar.gz'; | ||
} | ||
} | ||
function getArchiveName() { | ||
return util.format('libxl-%s-latest.%s', getPlaform(), isWin ? 'zip' : 'tar.gz'); | ||
return util.format('libxl-%s-latest.%s', getPlaform(), getArchiveSuffix()); | ||
} | ||
@@ -129,3 +144,3 @@ | ||
var downloadIfNecessary = function(callback) { | ||
function downloadIfNecessary(callback) { | ||
var suppliedArchive = process.env[archiveEnv]; | ||
@@ -143,15 +158,16 @@ | ||
var extractor = function(file, target, callback) { | ||
console.log('Extracting ' + file + ' ...'); | ||
function findSubdir(dir, pattern) { | ||
var files = fs.readdirSync(dir), | ||
i, | ||
file; | ||
for (i = 0; i < files.length; i++) { | ||
file = files[i]; | ||
if (file.match(pattern)) { | ||
return path.join(dir, file); | ||
} | ||
} | ||
return null; | ||
}; | ||
if (file.match(/\.zip$/)) { | ||
extractZip(file, target, callback); | ||
} else if (file.match(/\.tar\.gz/)) { | ||
extractTgz(file, target, callback); | ||
} else { | ||
callback(new Error('unnown archive format')); | ||
} | ||
}; | ||
var extractTgz = function(archive, destination, callback) { | ||
function extractTgz(archive, destination, callback) { | ||
var fileStream = fs.createReadStream(archive), | ||
@@ -164,3 +180,3 @@ decompressedStream = fileStream.pipe(zlib.createGunzip()), | ||
}); | ||
[fileStream, decompressedStream, untarStream].forEach(function(stream) { | ||
@@ -175,3 +191,3 @@ stream.on('error', function(e) { | ||
var extractZip = function(archive, destination, callback) { | ||
function extractZip(archive, destination, callback) { | ||
var zip; | ||
@@ -189,13 +205,77 @@ | ||
var finder = function(dir, pattern) { | ||
var files = fs.readdirSync(dir), | ||
i, | ||
file; | ||
for (i = 0; i < files.length; i++) { | ||
file = files[i]; | ||
if (file.match(pattern)) { | ||
return path.join(dir, file); | ||
function extractDmg(image, destination, callback) { | ||
childProcess.execFile('hdiutil', ['mount', '-plist', image], {encoding: 'utf8'}, function(err, stdout) { | ||
var result, candidates, i, mountpoint, sdkdir; | ||
function unmount(cb) { | ||
var tries = 0; | ||
function work() { | ||
childProcess.execFile('hdiutil', ['unmount', mountpoint], function(err) { | ||
if (err && tries++ < 5) { | ||
setTimeout(work, 1000); | ||
} else { | ||
cb(err); | ||
} | ||
}); | ||
} | ||
if (mountpoint) { | ||
work(); | ||
} else { | ||
cb(); | ||
} | ||
} | ||
if (err) { | ||
callback(new Error(util.format("failed to mount %s: %s", image, err.message))); | ||
return; | ||
} | ||
try { | ||
result = plist.parse(stdout); | ||
candidates = result['system-entities']; | ||
if (!candidates) throw new Error(); | ||
for (i = 0; i < candidates.length; i++) { | ||
if (mountpoint = candidates[i]['mount-point']) break; | ||
} | ||
if (!mountpoint) throw Error(); | ||
} catch (e) { | ||
callback(new Error('failed to identify dmg mountpoint')); | ||
return; | ||
} | ||
sdkdir = findSubdir(mountpoint, /^libxl/); | ||
if (!sdkdir) { | ||
unmount(function() { | ||
callback(new Error('SDK not found in dmg')); | ||
}); | ||
return; | ||
} | ||
childProcess.execFile('cp', ['-r', findSubdir(mountpoint, /^libxl/), destination], function(err) { | ||
unmount(function() { | ||
callback(err); | ||
}); | ||
}); | ||
}) | ||
} | ||
function extractArchive(file, target, callback) { | ||
console.log('Extracting ' + file + ' ...'); | ||
if (file.match(/\.zip$/)) { | ||
extractZip(file, target, callback); | ||
} else if (file.match(/\.tar\.gz/)) { | ||
extractTgz(file, target, callback); | ||
} else if (file.match(/\.dmg$/)) { | ||
extractDmg(file, target, callback); | ||
} else { | ||
callback(new Error('unnown archive format')); | ||
} | ||
return null; | ||
}; | ||
@@ -213,3 +293,3 @@ | ||
downloadIfNecessary(function(archive) { | ||
extractor(archive, dependencyDir, function(e) { | ||
extractArchive(archive, dependencyDir, function(e) { | ||
if (e) { | ||
@@ -222,3 +302,3 @@ console.error(e.message || 'Extraction failed'); | ||
var extractedDir = finder(dependencyDir, /^libxl/); | ||
var extractedDir = findSubdir(dependencyDir, /^libxl/); | ||
console.log('Renaming ' + extractedDir + ' to ' + libxlDir + ' ...'); | ||
@@ -225,0 +305,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "Node bindings for the libxl library for reading and writing excel (XLS and XLSX) spreadsheets.", | ||
@@ -42,3 +42,4 @@ "keywords": [ | ||
"tar": "~4.4.10", | ||
"tmp": "~0.0.29" | ||
"tmp": "~0.0.29", | ||
"plist": "~3.0.1" | ||
}, | ||
@@ -45,0 +46,0 @@ "devDependencies": { |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
307724
1787
6
3
+ Addedplist@~3.0.1
+ Addedbase64-js@1.5.1(transitive)
+ Addedplist@3.0.6(transitive)
+ Addedxmlbuilder@15.1.1(transitive)