Skip to content

Commit 18a7bee

Browse files
fubhyJannis
authored andcommitted
Fix path for copying the schema file.
1 parent 5bcacf3 commit 18a7bee

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/compiler.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class Compiler {
170170
_copySubgraphFile(maybeRelativeFile, sourceDir, targetDir, spinner) {
171171
let absoluteSourceFile = path.resolve(sourceDir, maybeRelativeFile)
172172
let relativeSourceFile = path.relative(sourceDir, absoluteSourceFile)
173-
let targetFile = path.join(targetDir, relativeSourceFile)
173+
let targetFile = path.resolve(targetDir, relativeSourceFile)
174174
step(spinner, 'Copy subgraph file', this.displayPath(targetFile))
175175
fs.mkdirsSync(path.dirname(targetFile))
176176
fs.copyFileSync(absoluteSourceFile, targetFile)
@@ -402,17 +402,14 @@ class Compiler {
402402
`Warnings while writing compiled subgraph to ${displayDir}`,
403403
async spinner => {
404404
// Copy schema and update its path
405-
subgraph = subgraph.updateIn(['schema', 'file'], schemaFile =>
406-
path.relative(
407-
this.options.outputDir,
408-
this._copySubgraphFile(
409-
schemaFile,
410-
this.sourceDir,
411-
this.options.outputDir,
412-
spinner,
413-
),
414-
),
415-
)
405+
subgraph = subgraph.updateIn(['schema', 'file'], schemaFile => {
406+
const schemaFilePath = path.resolve(this.sourceDir, schemaFile)
407+
const schemaFileName = path.basename(schemaFile)
408+
const targetFile = path.resolve(this.options.outputDir, schemaFileName)
409+
step(spinner, 'Copy schema file', this.displayPath(targetFile))
410+
fs.copyFileSync(schemaFilePath, targetFile)
411+
return path.relative(this.options.outputDir, targetFile)
412+
})
416413

417414
// Copy data source files and update their paths
418415
subgraph = subgraph.update('dataSources', dataSources => {

0 commit comments

Comments
 (0)