mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
Merge remote-tracking branch 'origin/update-examples'
This commit is contained in:
commit
ef6c04d1cb
8 changed files with 30 additions and 5 deletions
|
@ -11,11 +11,36 @@
|
|||
|
||||
const CWD = process.cwd();
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const glob = require("glob");
|
||||
|
||||
let examplesFolder = "examples";
|
||||
if (process.argv.indexOf("translations") !== -1) {
|
||||
fs.copySync(__dirname + "/../examples-translations/", CWD, {
|
||||
overwrite: false
|
||||
});
|
||||
} else {
|
||||
fs.copySync(__dirname + "/../examples/", CWD, { overwrite: false });
|
||||
examplesFolder = "examples-translations";
|
||||
}
|
||||
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) +
|
||||
". Remove or rename the file to regenerate this example file."
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue