Skip to content

Commit 5ea252a

Browse files
authored
Merge pull request #7 from mika-f/fix/windows-path-separator
Windows 環境での名前解決の失敗の修正
2 parents 1ffccdb + 8ae4d96 commit 5ea252a

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"dependencies": {
2828
"is-glob": "^4.0.3",
2929
"micromatch": "^4.0.4",
30+
"normalize-path": "^3.0.0",
3031
"require-strip-json-comments": "^2.0.0"
3132
},
3233
"devDependencies": {

strict-dependencies/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const path = require('path')
44
const mm = require('micromatch')
55
const isGlob = require('is-glob')
6+
const normalize = require('normalize-path')
67

78
const resolveImportPath = require('./resolveImportPath')
89

@@ -60,7 +61,7 @@ module.exports = {
6061

6162
function checkImport(node) {
6263
const fileFullPath = context.getFilename()
63-
const relativeFilePath = path.relative(process.cwd(), fileFullPath)
64+
const relativeFilePath = normalize(path.relative(process.cwd(), fileFullPath))
6465
const importPath = resolveImportPath(node.source.value, resolveRelativeImport ? relativeFilePath : null)
6566

6667
dependencies

strict-dependencies/resolveImportPath.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const path = require('path')
44
const parseJSON = require('require-strip-json-comments')
5+
const normalize = require('normalize-path')
56

67
/**
78
* import文のrootからのパスを求める
@@ -30,8 +31,10 @@ module.exports = (importPath, relativeFilePath) => {
3031
importPath = path.join(path.dirname(relativeFilePath), importPath)
3132
}
3233

33-
return Object.keys(importAliasMap).reduce((resolvedImportPath, key) => {
34+
const absolutePath = Object.keys(importAliasMap).reduce((resolvedImportPath, key) => {
3435
// FIXME: use glob module instead of replace('*')
3536
return resolvedImportPath.replace(key.replace('*', ''), importAliasMap[key].replace('*', ''))
3637
}, importPath)
38+
39+
return normalize(absolutePath)
3740
}

0 commit comments

Comments
 (0)