mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-05 04:12:53 +02:00
fix(v2): swizzle should be able to handle single js file (#1846)
* fix(v2): swizzle should be able to handle single js file * nits
This commit is contained in:
parent
d96b5f99b9
commit
7e60a283f1
2 changed files with 8 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
||||||
- Fix `keywords` frontmatter for SEO not working properly.
|
- Fix `keywords` frontmatter for SEO not working properly.
|
||||||
- Fix `swizzle` command not passing context properly to theme packages.
|
- Fix `swizzle` command not passing context properly to theme packages.
|
||||||
- Add `extendCli` api for plugins. This will allow plugin to further extend Docusaurus CLI.
|
- Add `extendCli` api for plugins. This will allow plugin to further extend Docusaurus CLI.
|
||||||
|
- Fix `swizzle` command not being able to swizzle single js file.
|
||||||
|
|
||||||
## 2.0.0-alpha.27
|
## 2.0.0-alpha.27
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,18 @@ export async function swizzle(
|
||||||
if (componentName) {
|
if (componentName) {
|
||||||
fromPath = path.join(fromPath, componentName);
|
fromPath = path.join(fromPath, componentName);
|
||||||
toPath = path.join(toPath, componentName);
|
toPath = path.join(toPath, componentName);
|
||||||
|
|
||||||
|
// Handle single js file only.
|
||||||
|
// E.g: if <fromPath> does not exist, we try to swizzle <fromPath>.js instead
|
||||||
|
if (!fs.existsSync(fromPath) && fs.existsSync(`${fromPath}.js`)) {
|
||||||
|
[fromPath, toPath] = [`${fromPath}.js`, `${toPath}.js`];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await fs.copy(fromPath, toPath);
|
await fs.copy(fromPath, toPath);
|
||||||
|
|
||||||
const relativeDir = path.relative(process.cwd(), toPath);
|
const relativeDir = path.relative(process.cwd(), toPath);
|
||||||
const fromMsg = chalk.blue(
|
const fromMsg = chalk.blue(
|
||||||
componentName ? `${themeName}/${componentName}` : themeName,
|
componentName ? `${themeName} ${chalk.yellow(componentName)}` : themeName,
|
||||||
);
|
);
|
||||||
const toMsg = chalk.cyan(relativeDir);
|
const toMsg = chalk.cyan(relativeDir);
|
||||||
console.log(
|
console.log(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue