Skip to content

Commit d4dd054

Browse files
author
Tyson Kunovsky
committed
Merge branch 'fix/custom-provider-with-forward-slash-naming' into 'master'
fix: Custom provider with forward slash in name See merge request auto-cloud/cloudgraph/cli!212
2 parents c722af4 + dbe4f8d commit d4dd054

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/utils/index.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,27 @@ export function makeDirIfNotExists(dir: string): void {
6363
}
6464
}
6565

66+
export function buildFixedPath(dir: string, provider?: string): string {
67+
const dirArray = provider?.replace(/\\/g, '/').includes('/')
68+
? provider?.replace(/\\/g, '/').split('/')
69+
: []
70+
return path.normalize(
71+
`${dir}/${dirArray.slice(0, dirArray.length - 1).join('/')}`
72+
)
73+
}
74+
6675
export function writeGraphqlSchemaToFile(
6776
dirPath: string,
6877
schema: string,
6978
provider?: string
7079
): void {
71-
makeDirIfNotExists(dirPath)
80+
makeDirIfNotExists(buildFixedPath(dirPath, provider))
7281
fs.writeFileSync(
73-
path.join(
74-
dirPath,
75-
provider ? `/${provider}_schema.graphql` : '/schema.graphql'
82+
path.normalize(
83+
path.join(
84+
dirPath,
85+
provider ? `/${provider}_schema.graphql` : '/schema.graphql'
86+
)
7687
),
7788
schema
7889
)

0 commit comments

Comments
 (0)