Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I add timestamp to my zipped file name #26

Open
iwangbowen opened this issue Nov 5, 2018 · 4 comments
Open

How can I add timestamp to my zipped file name #26

iwangbowen opened this issue Nov 5, 2018 · 4 comments

Comments

@iwangbowen
Copy link

I use this library as one of my npm scripts. Any suggestions on how I can add timestamp to the zipped file.

@nfriedly
Copy link
Owner

nfriedly commented Nov 5, 2018

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.

@AdrianoCahete
Copy link

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.

@nfriedly
Copy link
Owner

nfriedly commented Jul 17, 2019

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}`)
});

@AdrianoCahete
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants