Skip to content

Commit

Permalink
updates copy
Browse files Browse the repository at this point in the history
  • Loading branch information
smohadjer committed Mar 31, 2023
1 parent 358b921 commit 2b63b90
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
52 changes: 39 additions & 13 deletions bin/copyPublic.js → bin/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,49 @@ function copyResources(folder) {
}
}

function copyAssets() {
const srcDir = './app/assets';
const destDir = './public/assets/';
function copyFile(source, destination) {
fse.pathExists(source, (err, exists) => {
if (err) {
console.log(err, source) // => null
}

//https://stackoverflow.com/questions/13786160/copy-folder-recursively-in-node-js
try {
fse.copySync(srcDir, destDir, {overwrite: true});
console.log(srcDir, 'was copied to ', destDir);
}
catch (err) {
console.error('error: ', err);
if (exists) {
fse.copy(source, destination, function (err) {
if (err){
console.log('An error occured while copying the folder.')
return console.error(err)
}
console.log(source, ' copy completed!')
});
}
});
}

function copyFolder(source, destination) {
if (fse.existsSync(source)) {
fse.copy(source, destination, function (err) {
if (err){
console.log('An error occured while copying the folder.')
return console.error(err)
}
console.log(source, ' copy completed!')
});
}
}

copyDependencies('css');
copyDependencies('js');
copyResources('img');
copyResources('fonts');
copyResources('js');
copyAssets();

copyFile('app/apple-touch-icon.png', 'public/apple-touch-icon.png');
copyFile('app/favicon.ico', 'public/favicon.ico');
copyFile('app/favicon-16x16.png', 'public/favicon-16x16.png');
copyFile('app/favicon-32x32.png', 'public/favicon-32x32.png');
copyFile('app/android-chrome-192x192.png', 'public/android-chrome-192x192.png');
copyFile('app/android-chrome-512x512.png', 'public/android-chrome-512x512.png');
copyFile('app/site.webmanifest', 'public/site.webmanifest');
copyFile('app/sitemap.xml', 'public/sitemap.xml');

copyFolder('app/assets', 'public/assets');
copyFolder('app/resources/img', 'public/resources/img');
copyFolder('app/resources/fonts', 'public/resources/fonts');
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build",
"version": "1.0.0",
"version": "1.0.1",
"description": "A frontend build for HTML Websites",
"repository": {
"type": "git",
Expand Down

0 comments on commit 2b63b90

Please sign in to comment.