mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-15 09:12:24 +02:00
fix(migrate): do not modify non-MD files (#6146)
* fix(migrate): do not modify non-MD files * Little refactor
This commit is contained in:
parent
9d95d786fa
commit
cc0a439e12
1 changed files with 16 additions and 12 deletions
|
@ -513,11 +513,13 @@ function migrateVersionedDocs(
|
||||||
});
|
});
|
||||||
const files = walk(path.join(newDir, 'versioned_docs'));
|
const files = walk(path.join(newDir, 'versioned_docs'));
|
||||||
files.forEach((pathToFile) => {
|
files.forEach((pathToFile) => {
|
||||||
const content = fs.readFileSync(pathToFile).toString();
|
if (path.extname(pathToFile) === '.md') {
|
||||||
fs.writeFileSync(
|
const content = fs.readFileSync(pathToFile).toString();
|
||||||
pathToFile,
|
fs.writeFileSync(
|
||||||
sanitizedFileContent(content.replace(versionRegex, ''), migrateMDFiles),
|
pathToFile,
|
||||||
);
|
sanitizedFileContent(content.replace(versionRegex, ''), migrateMDFiles),
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -696,8 +698,10 @@ function migrateLatestDocs(
|
||||||
);
|
);
|
||||||
const files = walk(path.join(siteDir, '..', 'docs'));
|
const files = walk(path.join(siteDir, '..', 'docs'));
|
||||||
files.forEach((file) => {
|
files.forEach((file) => {
|
||||||
const content = String(fs.readFileSync(file));
|
if (path.extname(file) === '.md') {
|
||||||
fs.writeFileSync(file, sanitizedFileContent(content, migrateMDFiles));
|
const content = fs.readFileSync(file).toString();
|
||||||
|
fs.writeFileSync(file, sanitizedFileContent(content, migrateMDFiles));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
logger.success('Migrated docs to version 2');
|
logger.success('Migrated docs to version 2');
|
||||||
} else {
|
} else {
|
||||||
|
@ -749,11 +753,11 @@ export async function migrateMDToMDX(
|
||||||
fs.mkdirpSync(newDir);
|
fs.mkdirpSync(newDir);
|
||||||
fs.copySync(siteDir, newDir);
|
fs.copySync(siteDir, newDir);
|
||||||
const files = walk(newDir);
|
const files = walk(newDir);
|
||||||
files.forEach((file) => {
|
files.forEach((filePath) => {
|
||||||
fs.writeFileSync(
|
if (path.extname(filePath) === '.md') {
|
||||||
file,
|
const content = fs.readFileSync(filePath).toString();
|
||||||
sanitizedFileContent(String(fs.readFileSync(file)), true),
|
fs.writeFileSync(filePath, sanitizedFileContent(content, true));
|
||||||
);
|
}
|
||||||
});
|
});
|
||||||
logger.success`Successfully migrated path=${siteDir} to path=${newDir}`;
|
logger.success`Successfully migrated path=${siteDir} to path=${newDir}`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue