Closed Sobranier closed 5 years ago
Can you show me your code?
const zip = require('bestzip'); const files = [{ source: './build/ios/', target: './build/zip/ios-bundle' }, { source: './build/android/', target: './build/zip/android-bundle' }]; files.forEach(function(item) { zip(item.target, [item.source], function(err) {
...
}) })
Ok, I think this may be related to the CWD change from 1.x to 2.x (which was the main breaking change).
What directory are you in when you start the node.js command? Are you in the same directory as where the build/
folder is?
I'm going to see if I can add a way to configure the cwd
, at least for programmatic usage.
Ok, I just pushed some changes, it should be released in v2.1 once CI completes.
I had to change the API to support an options object, so I took this as a good opportunity to move the whole thing to be promise-based (mainly for easier usage with async / await).
(The old API still exists for backwards-compatibility, but doesn't have any to specify the cwd.)
You'll need to do something like this in your code:
const zip = require('bestzip');
const path = require('path');
const files = [{
cwd: path.join(__dirname, '../build/ios/'), // change this line if necessary
source: './',
destination: '../zip/ios-bundle' // note: key changed from 'target' to 'destination'.
}, {
cwd: path.join(__dirname, '../build/android/'), // ditto
source: './',
destination: '../zip/android-bundle' // ditto
}];
files.forEach(function(item) {
zip(item).then(function() {
//...
}).catch(function(err) {
//...
});
});
Hey, just a quick followup: v2.1.0 had a bug on windows; I just pushed 2.1.1 with the fix.
when i use this below directorily, it works fine
but when i use it in an node file, it crashed
v1.4.X works v2.0.0 crashed