Created
April 4, 2015 22:19
-
-
Save twalker/1a0e4bad3979c3063685 to your computer and use it in GitHub Desktop.
cp.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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