mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 08:07:26 +02:00
Update examples script to print messages and move docs/blog examples to folder outside of website
This commit is contained in:
parent
ea4a4f6fe3
commit
c9f3f6a7dd
8 changed files with 25 additions and 5 deletions
|
@ -11,11 +11,31 @@
|
||||||
|
|
||||||
const CWD = process.cwd();
|
const CWD = process.cwd();
|
||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
|
const path = require("path");
|
||||||
|
const glob = require("glob");
|
||||||
|
|
||||||
|
let examplesFolder = "examples";
|
||||||
if (process.argv.indexOf("translations") !== -1) {
|
if (process.argv.indexOf("translations") !== -1) {
|
||||||
fs.copySync(__dirname + "/../examples-translations/", CWD, {
|
examplesFolder = "examples-translations";
|
||||||
overwrite: false
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
fs.copySync(__dirname + "/../examples/", CWD, { overwrite: false });
|
|
||||||
}
|
}
|
||||||
|
const files = glob.sync(path.join(__dirname, "..", examplesFolder, "**"));
|
||||||
|
files.forEach(file => {
|
||||||
|
if (!fs.lstatSync(file).isDirectory()) {
|
||||||
|
let target = CWD;
|
||||||
|
if (file.includes("-examples")) {
|
||||||
|
target = path.join(CWD, "..");
|
||||||
|
}
|
||||||
|
let fileName = file.substring(file.indexOf(examplesFolder) + examplesFolder.length);
|
||||||
|
try {
|
||||||
|
fs.copySync(file, path.join(target, fileName), {
|
||||||
|
overwrite: false,
|
||||||
|
errorOnExist: true
|
||||||
|
});
|
||||||
|
console.log(fileName + " created in " + path.basename(target));
|
||||||
|
} catch (e) {
|
||||||
|
console.log(
|
||||||
|
fileName + " already exists in " + path.basename(target)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue