-
Notifications
You must be signed in to change notification settings - Fork 398
Closed
Labels
status: needs triageIssues which needs to be reproduced to be verified report.Issues which needs to be reproduced to be verified report.type: fixIssues describing a broken feature.Issues describing a broken feature.
Description
Description
I used routing-controllers about 2 years ago everything was fine. But today I created a new project and got strange issue.
const app = createExpressServer({
controllers: [path.join(__dirname,"/api/controllers/*.ts")], // we specify controllers we want to use
});
doesn't find controllers on Windows
Expected behavior
const app = createExpressServer({
controllers: [path.join(__dirname,"/api/controllers/*.ts")], // we specify controllers we want to use
});
controllers are found
Actual behavior
path.join converted to \api\controllers (windows slash) and glob failing
const app = createExpressServer({
controllers: [path.join(__dirname,"/api/controllers/*.ts").replace(/\\/g, '/')], // we specify controllers we want to use
});
still no luck, because in /util/importClassesFromDirectories.js
const allFiles = directories.reduce((allDirs, dir) => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
return allDirs.concat(require('glob').sync(path.normalize(dir)));
}, []);
path.normalize again converts / to \ and glob failing again
after removing path.normalize (hardcoded in node_modules for science)
const allFiles = directories.reduce((allDirs, dir) => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// return allDirs.concat(require('glob').sync(path.normalize(dir)));
return allDirs.concat(require('glob').sync(dir));
}, []);
controllers are finally found
Is it a bug ? Or i need some better workarounds ?
Environment
Windows 11
Node v16.13.1
"glob":"8.0.3"
"typedi": "^0.10.0",
"routing-controllers":"0.10.0"
"typescript": "^4.9.4"
"ts-node-dev": "^2.0.0" (issue reproduced in compiled js too though)
Metadata
Metadata
Assignees
Labels
status: needs triageIssues which needs to be reproduced to be verified report.Issues which needs to be reproduced to be verified report.type: fixIssues describing a broken feature.Issues describing a broken feature.