Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env node
- const { promisify } = require('util');
- /* eslint-disable import/no-extraneous-dependencies */
- const glob = promisify(require('glob'));
- /* eslint-enable */
- const cryptFile = require('../util/cryptFile');
- const handler = async (command, secret, ...filePathArgs) => {
- const files = (await Promise.all(
- filePathArgs.map(pattern => glob(pattern)),
- )).reduce((acc, paths) => [...acc, ...paths], []);
- const results = await cryptFile({
- command,
- secret,
- files,
- });
- results.forEach(({ error, path }) => {
- if (error) { console.log(error, path); }
- });
- console.log('Completed', command === 'encrypt' ? 'encrypting' : 'decrypting', 'files');
- };
- handler(...process.argv.slice(2));
Add Comment
Please, Sign In to add comment