Skip to content

Commit c47dca9

Browse files
committed
feat: create output directory if it does not exist
Closes #15
1 parent 18243c1 commit c47dca9

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
},
2727
"homepage": "https://github.com/supergraphql/graphql-cli-prepare#readme",
2828
"devDependencies": {
29+
"@types/fs-extra": "5.0.0",
2930
"@types/inquirer": "0.0.36",
3031
"@types/node": "8.5.2",
3132
"@types/yargs": "10.0.0",
@@ -40,6 +41,7 @@
4041
},
4142
"dependencies": {
4243
"chalk": "2.3.0",
44+
"fs-extra": "5.0.0",
4345
"graphql-import": "0.1.9",
4446
"graphql-static-binding": "0.2.1",
4547
"lodash": "4.17.4"

src/prepare.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import chalk from 'chalk'
2-
import * as fs from 'fs'
2+
import * as fs from 'fs-extra'
33
import { Context } from 'graphql-cli'
44
import { GraphQLProjectConfig } from 'graphql-config'
55
import { importSchema } from 'graphql-import'
@@ -223,9 +223,7 @@ export class Prepare {
223223
)
224224
}
225225

226-
if (!fs.existsSync(path.dirname(outputPath))) {
227-
throw new Error(`Output path '${path.dirname(outputPath)}' does not exist.`)
228-
}
226+
fs.ensureDirSync(path.dirname(outputPath))
229227
return outputPath
230228
}
231229
}

yarn.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
version "0.6.0"
7474
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.6.0.tgz#383f456b26bc96c7889f0332079f4358b16c58dc"
7575

76+
"@types/fs-extra@^5.0.0":
77+
version "5.0.0"
78+
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-5.0.0.tgz#d3e225b35eb5c6d3a5a782c28219df365c781413"
79+
dependencies:
80+
"@types/node" "*"
81+
7682
"@types/graphql@0.11.7":
7783
version "0.11.7"
7884
resolved "https://registry.yarnpkg.com/@types/graphql/-/graphql-0.11.7.tgz#da39a2f7c74e793e32e2bb7b3b68da1691532dd5"

0 commit comments

Comments
 (0)