Skip to content

Instantly share code, notes, and snippets.

@twalker
Created April 4, 2015 22:19
Show Gist options
  • Save twalker/1a0e4bad3979c3063685 to your computer and use it in GitHub Desktop.
Save twalker/1a0e4bad3979c3063685 to your computer and use it in GitHub Desktop.
cp.js
#!/usr/bin/env node
/*
An OS-agnostic file/dir copy (cp).
// copy a single file to a new location
./cp.js foo/existing.txt foo/newname.txt
// copy contents of a directory into another
./cp.js foo/ bar/
*/
var fs = require('fs-extra')
args = process.argv.slice(2),
src = args[0],
dest = args[1];
fs.copy(src, dest, function(err){
if(err) throw(err)
process.stdout.write(src + ' => ' + dest + '\n');
process.exit(0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment