Last active
August 29, 2015 13:57
-
-
Save cowboy/9413617 to your computer and use it in GitHub Desktop.
globule.mapping new rename src/dest example
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
var globule = require('globule'); | |
// This actually looks for files '1' '2' etc, doesn't find them, | |
// but retains the pattern because nonull == true | |
console.log(globule.findMappingSync({ | |
src: '12345'.split(''), | |
nonull: true, | |
rename: function(n) { | |
return { | |
src: 'in/' + n + '.txt', | |
dest: 'out/' + n + '.txt', | |
}; | |
}, | |
})); | |
[ { src: [ 'in/1.txt' ], dest: 'out/1.txt' }, | |
{ src: [ 'in/2.txt' ], dest: 'out/2.txt' }, | |
{ src: [ 'in/3.txt' ], dest: 'out/3.txt' }, | |
{ src: [ 'in/4.txt' ], dest: 'out/4.txt' }, | |
{ src: [ 'in/5.txt' ], dest: 'out/5.txt' } ] | |
// This doesn't use the filesystem at all, it just creates | |
// the mapping | |
console.log(globule.mapping({ | |
src: '12345'.split(''), | |
rename: function(n) { | |
return { | |
src: 'in/' + n + '.txt', | |
dest: 'out/' + n + '.txt', | |
}; | |
}, | |
})); | |
[ { src: [ 'in/1.txt' ], dest: 'out/1.txt' }, | |
{ src: [ 'in/2.txt' ], dest: 'out/2.txt' }, | |
{ src: [ 'in/3.txt' ], dest: 'out/3.txt' }, | |
{ src: [ 'in/4.txt' ], dest: 'out/4.txt' }, | |
{ src: [ 'in/5.txt' ], dest: 'out/5.txt' } ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment