Skip to content

Commit 409a2ad

Browse files
committed
chore: use separator constants from path
1 parent 32c6271 commit 409a2ad

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

packages/amplify-codegen/src/commands/models.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const defaultDirectiveDefinitions = require('../utils/defaultDirectiveDefinition
88
const getProjectRoot = require('../utils/getProjectRoot');
99
const { getModelSchemaPathParam, hasModelSchemaPathParam } = require('../utils/getModelSchemaPathParam');
1010
const { isDataStoreEnabled } = require('graphql-transformer-core');
11+
const { normalizePathForGlobPattern } = require('../utils/input-params-manager');
1112

1213
/**
1314
* Amplify Context type.
@@ -305,7 +306,7 @@ function loadSchema(apiResourcePath) {
305306
}
306307
if (fs.pathExistsSync(schemaDirectory) && fs.lstatSync(schemaDirectory).isDirectory()) {
307308
// search recursively for graphql schema files inside `schema` directory
308-
const schemas = globby.sync([path.join(schemaDirectory, '**/*.graphql')].map((path) => path.replace(/\\/g, '/')));
309+
const schemas = globby.sync([path.join(schemaDirectory, '**/*.graphql')].map((path) => normalizePathForGlobPattern(path)));
309310
return schemas.map(file => fs.readFileSync(file, 'utf8')).join('\n');
310311
}
311312

packages/amplify-codegen/src/commands/types.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { loadConfig } = require('../codegen-config');
99
const { ensureIntrospectionSchema, getFrontEndHandler, getAppSyncAPIDetails, getAppSyncAPIInfoFromProject } = require('../utils');
1010
const { generateTypes: generateTypesHelper } = require('@aws-amplify/graphql-generator');
1111
const { extractDocumentFromJavascript } = require('@aws-amplify/graphql-types-generator');
12+
const { normalizePathForGlobPattern } = require('../utils/input-params-manager');
1213

1314
async function generateTypes(context, forceDownloadSchema, withoutInit = false, decoupleFrontend = '') {
1415
let frontend = decoupleFrontend;
@@ -58,7 +59,8 @@ async function generateTypes(context, forceDownloadSchema, withoutInit = false,
5859
const target = cfg.amplifyExtension.codeGenTarget;
5960

6061
const excludes = cfg.excludes.map(pattern => `!${pattern}`);
61-
const queryFilePaths = globby.sync([...includeFiles, ...excludes].map((path) => path.replace(/\\/g, '/')), {
62+
const normalizedPatterns = [...includeFiles, ...excludes].map((path) => normalizePathForGlobPattern(path));
63+
const queryFilePaths = globby.sync(normalizedPatterns, {
6264
cwd: projectPath,
6365
absolute: true,
6466
});

packages/amplify-codegen/src/utils/input-params-manager.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const constants = require('../constants');
2+
const path = require('path');
23

34
function normalizeInputParams(context) {
45
let inputParams;
@@ -66,6 +67,12 @@ function normalizeValue(key, value) {
6667
return value;
6768
}
6869

70+
function normalizePathForGlobPattern(pattern) {
71+
const splits = pattern.split(path.win32.sep);
72+
return splits.join(path.posix.sep);
73+
}
74+
6975
module.exports = {
7076
normalizeInputParams,
77+
normalizePathForGlobPattern,
7178
};

0 commit comments

Comments
 (0)