mirror of
https://github.com/fengyuanchen/viewerjs.git
synced 2026-01-25 15:23:40 +00:00
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const pkg = require('../package');
|
|
|
|
const dist = path.join(__dirname, '../dist/');
|
|
const docs = path.join(__dirname, '../docs/');
|
|
const now = new Date();
|
|
const banner = `/*!
|
|
* Viewer.js v${pkg.version}
|
|
* https://github.com/${pkg.repository}
|
|
*
|
|
* Copyright (c) ${now.getFullYear()} ${pkg.author.name}
|
|
* Released under the ${pkg.license} license
|
|
*
|
|
* Date: ${now.toISOString()}
|
|
*/
|
|
|
|
`;
|
|
|
|
fs.readdirSync(dist).forEach((file) => {
|
|
if (!/\.(js|css)$/.test(file)) {
|
|
return;
|
|
}
|
|
|
|
const filePath = path.join(dist, file);
|
|
const fileData = banner + fs.readFileSync(filePath, 'utf8').toString();
|
|
|
|
fs.writeFile(filePath, fileData, (err) => {
|
|
if (err) {
|
|
throw err;
|
|
}
|
|
|
|
console.log(`Added banner to ${file}.`);
|
|
|
|
if (file === 'viewer.js') {
|
|
fs.writeFile(path.join(docs, 'js/', file), fileData, (e) => {
|
|
if (e) {
|
|
throw e;
|
|
}
|
|
|
|
console.log(`Copied ${file} to docs/js.`);
|
|
});
|
|
} else if (file === 'viewer.css') {
|
|
fs.writeFile(path.join(docs, 'css/', file), fileData, (e) => {
|
|
if (e) {
|
|
throw e;
|
|
}
|
|
|
|
console.log(`Copied ${file} to docs/css.`);
|
|
});
|
|
}
|
|
});
|
|
});
|