pico-content-editor/js/extract-files-from-node-modules.js
2023-02-22 18:55:40 +01:00

87 lines
1.9 KiB
JavaScript

/*
* SPDX-License-Identifier: EUPL-1.2
* Authors: see README.md
*/
// Extract files that we need from the node_modules folder
// The extracted files are integrated to the repository, so production server don't need to
// have node installed
// Include fs and path module
const fs = require('fs-extra')
const path = require('path')
const basePath = path.join(__dirname, '../')
function copySync(src, dest, opts) {
let parentFolder = path.dirname(dest)
if (!fs.existsSync(parentFolder)){
fs.mkdirsSync(parentFolder,{recursive:true})
}
if (fs.existsSync(src)) {
fs.copySync(path.join(basePath, src), path.join(basePath, dest), opts)
} else {
console.log(`${src} is not existing !`)
}
}
// ContentTools
copySync(
'node_modules/ContentTools/build/content-tools.min.css',
'css/vendor/ContentTools/content-tools.min.css',
{ overwrite: true }
)
copySync(
'node_modules/ContentTools/build/images/',
'css/vendor/ContentTools/images/',
{ overwrite: true }
)
copySync(
'node_modules/ContentTools/LICENSE',
'css/vendor/ContentTools/LICENSE',
{ overwrite: true }
)
copySync(
'node_modules/ContentTools/build/content-tools.min.js',
'js/vendor/ContentTools/content-tools.min.js',
{ overwrite: true }
)
copySync(
'node_modules/ContentTools/translations/',
'js/vendor/ContentTools/translations/',
{ overwrite: true }
)
copySync(
'node_modules/ContentTools/LICENSE',
'js/vendor/ContentTools/LICENSE',
{ overwrite: true }
)
// Noty
copySync(
'node_modules/noty/lib/noty.min.js',
'js/vendor/noty/noty.min.js',
{ overwrite: true }
)
copySync(
'node_modules/noty/LICENSE.txt',
'js/vendor/noty/LICENSE',
{ overwrite: true }
)
copySync(
'node_modules/noty/lib/noty.css',
'css/vendor/noty/noty.css',
{ overwrite: true }
)
copySync(
'node_modules/noty/LICENSE.txt',
'css/vendor/noty/LICENSE',
{ overwrite: true }
)
copySync(
'node_modules/noty/lib/themes/mint.css',
'css/vendor/noty/themes/mint.css',
{ overwrite: true }
)