Skip to content

Commit

Permalink
fix: replace all occurrences, not just the first one
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Oct 8, 2021
1 parent 618a393 commit 1f6e1b0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/cli-plugin-scaffold-graphql-api/src/index.ts
Expand Up @@ -174,7 +174,7 @@ export default (): CliCommandScaffoldTemplate<Input> => ({
path.join(context.project.root, input.path, "code", "graphql"),
context.project.root
)
.replace("\\", "/")
.replace(/\\/g, "/")
}
];
replaceInPath(p, replacements);
Expand All @@ -191,7 +191,7 @@ export default (): CliCommandScaffoldTemplate<Input> => ({
path.join(context.project.root, input.path, "code", "graphql"),
context.project.root
)
.replace("\\", "/")
.replace(/\\/g, "/")
}
];
replaceInPath(p, replacements);
Expand Down Expand Up @@ -221,7 +221,7 @@ export default (): CliCommandScaffoldTemplate<Input> => ({

// Add package to workspaces.
const rootPackageJsonPath = path.join(context.project.root, "package.json");
const pathToAdd = `${input.path}/code/graphql`.replace("\\", "/");
const pathToAdd = `${input.path}/code/graphql`.replace(/\\/g, "/");
await addWorkspaceToRootPackageJson(rootPackageJsonPath, pathToAdd);

ora.stopAndPersist({
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-plugin-scaffold-react-app/src/index.ts
Expand Up @@ -174,7 +174,7 @@ export default (): CliCommandScaffoldTemplate<Input> => ({

// Add package to workspaces.
const rootPackageJsonPath = path.join(context.project.root, "package.json");
const pathToAdd = `${input.path}/code`.replace("\\", "/");
const pathToAdd = `${input.path}/code`.replace(/\\/g, "/");
await addWorkspaceToRootPackageJson(rootPackageJsonPath, pathToAdd);

ora.stopAndPersist({
Expand Down
Expand Up @@ -5,7 +5,7 @@ import { PackageJson } from "@webiny/cli-plugin-scaffold/types";

export default async (packageJsonPath, pathToAdd) => {
// Ensure forward slashes are used.
pathToAdd = pathToAdd.replace("\\", "/");
pathToAdd = pathToAdd.replace(/\\/g, "/");

const rootPackageJson = await readJson<PackageJson>(packageJsonPath);
if (!rootPackageJson.workspaces.packages.includes(pathToAdd)) {
Expand Down

0 comments on commit 1f6e1b0

Please sign in to comment.