in make-util.js [441:506]
var copyGroup = function (group, sourceRoot, destRoot) {
// example structure to copy a single file:
// {
// "source": "foo.dll"
// }
//
// example structure to copy an array of files/folders to a relative directory:
// {
// "source": [
// "foo.dll",
// "bar",
// ],
// "dest": "baz/",
// "options": "-R"
// }
//
// example to multiply the copy by .NET culture names supported by TFS:
// {
// "source": "<CULTURE_NAME>/foo.dll",
// "dest": "<CULTURE_NAME>/"
// }
//
// validate parameters
assert(group, 'group');
assert(group.source, 'group.source');
if (typeof group.source == 'object') {
assert(group.source.length, 'group.source.length');
group.source.forEach(function (s) {
assert(s, 'group.source[i]');
});
}
assert(sourceRoot, 'sourceRoot');
assert(destRoot, 'destRoot');
// multiply by culture name (recursive call to self)
if (group.dest && group.dest.indexOf('<CULTURE_NAME>') >= 0) {
cultureNames.forEach(function (cultureName) {
// culture names do not contain any JSON-special characters, so this is OK (albeit a hack)
var localizedGroupJson = JSON.stringify(group).replace(/<CULTURE_NAME>/g, cultureName);
copyGroup(JSON.parse(localizedGroupJson), sourceRoot, destRoot);
});
return;
}
// build the source array
var source = typeof group.source == 'string' ? [ group.source ] : group.source;
source = source.map(function (val) { // root the paths
return path.join(sourceRoot, val);
});
// create the destination directory
var dest = group.dest ? path.join(destRoot, group.dest) : destRoot + '/';
dest = path.normalize(dest);
mkdir('-p', dest);
// copy the files
if (group.hasOwnProperty('options') && group.options) {
cp(group.options, source, dest);
}
else {
cp(source, dest);
}
}