Skip to content

Instantly share code, notes, and snippets.

@argentinaluiz
Created February 4, 2019 07:57
Show Gist options
  • Save argentinaluiz/2d26963b58462c142db920690e48d1ee to your computer and use it in GitHub Desktop.
Save argentinaluiz/2d26963b58462c142db920690e48d1ee to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
// each object in the array consists of a key which refers to the source and
// the value which is the destination.
const filestocopy = [
{
"./icons/drawable-hdpi/ic_stat_school.png": [
"./platforms/android/app/src/main/res/drawable-land-hdpi/ic_stat_school.png",
"./platforms/android/app/src/main/res/drawable-port-hdpi/ic_stat_school.png",
],
"./icons/drawable-mdpi/ic_stat_school.png": [
"./platforms/android/app/src/main/res/drawable-land-mdpi/ic_stat_school.png",
"./platforms/android/app/src/main/res/drawable-port-mdpi/ic_stat_school.png",
],
"./icons/drawable-xhdpi/ic_stat_school.png": [
"./platforms/android/app/src/main/res/drawable-land-xhdpi/ic_stat_school.png",
"./platforms/android/app/src/main/res/drawable-port-xhdpi/ic_stat_school.png",
],
"./icons/drawable-xxhdpi/ic_stat_school.png": [
"./platforms/android/app/src/main/res/drawable-land-xxhdpi/ic_stat_school.png",
"./platforms/android/app/src/main/res/drawable-port-xxhdpi/ic_stat_school.png",
],
"./icons/drawable-xxxhdpi/ic_stat_school.png": [
"./platforms/android/app/src/main/res/drawable-land-xxxhdpi/ic_stat_school.png",
"./platforms/android/app/src/main/res/drawable-port-xxxhdpi/ic_stat_school.png",
],
},
];
const fs = require('fs');
const path = require('path');
filestocopy.forEach((obj) => {
Object.keys(obj).forEach((key) => {
const srcfile = key;
for(const val of obj[key]){
const destfile = val;
console.log("copying "+srcfile+" to "+destfile);
const destdir = path.dirname(destfile);
if (fs.existsSync(srcfile) && fs.existsSync(destdir)) {
fs.createReadStream(srcfile).pipe(
fs.createWriteStream(destfile));
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment