Skip to content

Commit

Permalink
fix: ensure forward slashes are used in import statements
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Oct 8, 2021
1 parent 8d627ab commit f86a2eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
22 changes: 13 additions & 9 deletions packages/cli-plugin-scaffold-graphql-api/src/index.ts
Expand Up @@ -169,10 +169,12 @@ export default (): CliCommandScaffoldTemplate<Input> => ({
const replacements = [
{
find: "PATH",
replaceWith: path.relative(
path.join(context.project.root, input.path, "code", "graphql"),
context.project.root
)
replaceWith: path
.relative(
path.join(context.project.root, input.path, "code", "graphql"),
context.project.root
)
.replace("\\", "/")
}
];
replaceInPath(p, replacements);
Expand All @@ -184,10 +186,12 @@ export default (): CliCommandScaffoldTemplate<Input> => ({
const replacements = [
{
find: "PATH",
replaceWith: path.relative(
path.join(context.project.root, input.path, "code", "graphql"),
context.project.root
)
replaceWith: path
.relative(
path.join(context.project.root, input.path, "code", "graphql"),
context.project.root
)
.replace("\\", "/")
}
];
replaceInPath(p, replacements);
Expand Down Expand Up @@ -217,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`;
const pathToAdd = `${input.path}/code/graphql`.replace("\\", "/");
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`;
const pathToAdd = `${input.path}/code`.replace("\\", "/");
await addWorkspaceToRootPackageJson(rootPackageJsonPath, pathToAdd);

ora.stopAndPersist({
Expand Down
Expand Up @@ -4,6 +4,9 @@ import writeJson from "write-json-file";
import { PackageJson } from "@webiny/cli-plugin-scaffold/types";

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

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

0 comments on commit f86a2eb

Please sign in to comment.