Open iwangbowen opened 5 years ago
If you're only using bash, then backticks and the date command might work:
{
"scripts": "bestzip `date`.zip build/"
}
(Backticks execute the command and then replace it with it's output in bash.)
Alternatively, you can write your own script using the programmatic api and do something like (new Date()).toString() + '.zip'
for the destination.
Isn't easy to make a new feature for this tool to add the date on file?
I'm running on Windows, but my builds machines are unix and windows. Will be way easier if the tool do this by itself.
Please, consider this idea.
I don't think that feature makes sense in the library - there's too many potential output formats for one thing. But you can write a very simple script that does exactly what you need. Something like this should work on windows and unix:
#!/usr/bin/env node
var zip = require('bestzip');
var dest = new Date()).toString() + '.zip' ;
zip({
source: 'build/*',
destination: dest,
}).then(() => {
console.log(`saved to ${dest}`)
});
there's too many potential output formats
To be honest, the only output acceptable as default (or for a first interaction) is to use ISO 8601.
But works with that script, thanks!
I use this library as one of my npm scripts. Any suggestions on how I can add timestamp to the zipped file.