Skip to content

Commit

Permalink
fix issue/61: split('/n') does not work on Windows (#89)
Browse files Browse the repository at this point in the history
* fix issue/61: split('/n') does not work on Windows

* remove redundant concat operator

* revert src/index.js changes
  • Loading branch information
dnalborczyk authored and jnwng committed May 30, 2017
1 parent 38b0c4f commit 70e77d9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions loader.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"use strict";

const os = require('os');
const gql = require('./src');

// Takes `source` (the source GraphQL query string)
// and `doc` (the parsed GraphQL document) and tacks on
// the imported definitions.
function expandImports(source, doc) {
const lines = source.split('\n');
const lines = source.split(os.EOL);
let outputCode = `
var names = {};
function unique(defs) {
Expand All @@ -30,7 +31,7 @@ function expandImports(source, doc) {
const importFile = line.slice(1).split(' ')[1];
const parseDocument = `require(${importFile})`;
const appendDef = `doc.definitions = doc.definitions.concat(unique(${parseDocument}.definitions));`;
outputCode += appendDef + "\n";
outputCode += appendDef + os.EOL;
}
return (line.length !== 0 && line[0] !== '#');
});
Expand All @@ -47,5 +48,5 @@ module.exports = function(source) {
`;
const importOutputCode = expandImports(source, doc);

return outputCode + "\n" + importOutputCode + "\n" + `module.exports = doc;`;
return outputCode + os.EOL + importOutputCode + os.EOL + `module.exports = doc;`;
};

0 comments on commit 70e77d9

Please sign in to comment.