Skip to content

Commit

Permalink
fix: create docs/en/packages folder in copy-package-readme.js script …
Browse files Browse the repository at this point in the history
…if said folder doesn't exist
  • Loading branch information
jkmdev committed Feb 17, 2019
1 parent ed0af87 commit eb54e92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
22 changes: 15 additions & 7 deletions build/documentation/copy-package-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ process.argv.forEach(function (val, index) {
*/
function copyReadmeFiles() {

if (dryRun) console.log("In docs/en/packages/, this script would...");

const resolvedSrcReadmePaths = path.resolve(rootDir, srcReadmePaths);

if (dryRun) console.log(`For ${destDir}, this script would...`);

createDirectory(destDir);
glob(resolvedSrcReadmePaths, {realpath:true}, function(error, srcFiles) {

srcFiles.forEach((srcReadmePath) => {
Expand Down Expand Up @@ -91,18 +93,14 @@ function createDestReadme(srcReadmePath) {
`sidebar_label: ${title}\n` +
`---\n\n`;

if (!fs.existsSync(destDirPath)) {
dryRun ? console.log(`...CREATE folder '${folderName}'`) : fs.mkdirSync(destDirPath);
}
createDirectory(destDirPath);

if (dryRun) {

if (fs.existsSync(destReadmePath)) {
console.log(`...REPLACE readme.md in the '${folderName}' folder`);
} else {
console.log(`...ADD readme.md into the '${folderName}' folder`);
}

} else {
try {
fs.writeFileSync(destReadmePath, docusaurusHeader);
Expand Down Expand Up @@ -140,6 +138,16 @@ function updateSidebar() {

}

/**
* Utility function that creates new folders
* based off destination argument
*/
function createDirectory(dir) {
if (!fs.existsSync(dir)) {
dryRun ? console.log(`...CREATE the '${dir}' folder.`) : fs.mkdirSync(dir);
}
}

/**
* Run script
* Based off presence of --dry-run parameter
Expand Down
1 change: 0 additions & 1 deletion website/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"en/packages/fast-markdown-msft-react/index",
"en/packages/fast-navigation-generator-react/index",
"en/packages/fast-permutator/index",
"en/packages/fast-sketch-library/index",
"en/packages/fast-tslint-rules/index",
"en/packages/fast-viewer-react/index",
"en/packages/fast-web-utilities/index"
Expand Down

0 comments on commit eb54e92

Please sign in to comment.