Skip to content

Commit 2c94b4c

Browse files
committed
Append terminating newline to output
1 parent 72500f7 commit 2c94b4c

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
## Upcoming
44

55
- `apollo`
6-
- <First `apollo` related entry goes here>
6+
- Introduce terminator parameter to `writeGeneratedFiles` function [#1226](https://github.com/apollographql/apollo-tooling/pull/1226)
77
- `apollo-codegen-core`
88
- <First `apollo-codegen-core` related entry goes here>
99
- `apollo-codegen-flow`
1010
- <First `apollo-codegen-flow` related entry goes here>
1111
- `apollo-codegen-scala`
1212
- <First `apollo-codegen-scala` related entry goes here>
1313
- `apollo-codegen-swift`
14-
- <First `apollo-codegen-swift` related entry goes here>
14+
- Append terminating newline character to generated files [#531](https://github.com/apollographql/apollo-ios/issues/531)
1515
- `apollo-codegen-typescript`
1616
- <First `apollo-codegen-typescript` related entry goes here>
1717
- `apollo-env`

packages/apollo/src/commands/client/__tests__/__snapshots__/generate.test.ts.snap

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ public final class SimpleQueryQuery: GraphQLQuery {
184184
}
185185
}
186186
}
187-
}"
187+
}
188+
"
188189
`;
189190

190191
exports[`client:codegen writes swift types from local schema in a graphql file 1`] = `
@@ -225,7 +226,8 @@ public final class SimpleQueryQuery: GraphQLQuery {
225226
}
226227
}
227228
}
228-
}"
229+
}
230+
"
229231
`;
230232

231233
exports[`client:codegen writes types for query with only client-side data 1`] = `

packages/apollo/src/generate.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ export default function generate(
7373
const generator = generateSwiftSource(context, outputIndividualFiles, only);
7474

7575
if (outputIndividualFiles) {
76-
writeGeneratedFiles(generator.generatedFiles, outputPath);
76+
writeGeneratedFiles(generator.generatedFiles, outputPath, "\n");
7777
writtenFiles += Object.keys(generator.generatedFiles).length;
7878
} else {
79-
fs.writeFileSync(outputPath, generator.output);
79+
fs.writeFileSync(outputPath, generator.output.concat("\n"));
8080
writtenFiles += 1;
8181
}
8282

@@ -215,12 +215,13 @@ export default function generate(
215215

216216
function writeGeneratedFiles(
217217
generatedFiles: { [fileName: string]: BasicGeneratedFile },
218-
outputDirectory: string
218+
outputDirectory: string,
219+
terminator: string = ""
219220
) {
220221
for (const [fileName, generatedFile] of Object.entries(generatedFiles)) {
221222
fs.writeFileSync(
222223
path.join(outputDirectory, fileName),
223-
generatedFile.output
224+
generatedFile.output.concat(terminator)
224225
);
225226
}
226227
}

0 commit comments

Comments
 (0)