mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-12-26 16:14:16 +03:00
Fix use of _atomModuleCache in getNativeModuleDependencyPaths
Previously, we weren’t converting the relative path from the module cache and the test wasn’t strong enough to detect this fact.
This commit is contained in:
parent
0717c1d377
commit
6b66bf7b0a
0
spec/fixtures/packages/package-with-cached-incompatible-native-module/main.js
vendored
Normal file
0
spec/fixtures/packages/package-with-cached-incompatible-native-module/main.js
vendored
Normal file
12
spec/fixtures/packages/package-with-cached-incompatible-native-module/package.json
vendored
Normal file
12
spec/fixtures/packages/package-with-cached-incompatible-native-module/package.json
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "package-with-cached-incompatible-native-module",
|
||||
"version": "1.0.0",
|
||||
"main": "./main.js",
|
||||
"_atomModuleCache": {
|
||||
"extensions": {
|
||||
".node": [
|
||||
"node_modules/native-module/build/Release/native.node"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "package-with-incompatible-native-module-and-atom-module-cache",
|
||||
"name": "package-with-ignored-incompatible-native-module",
|
||||
"version": "1.0.0",
|
||||
"main": "./main.js",
|
||||
"_atomModuleCache": {
|
||||
|
@ -19,13 +19,16 @@ describe "Package", ->
|
||||
expect(pack.incompatibleModules[0].name).toBe 'native-module'
|
||||
expect(pack.incompatibleModules[0].path).toBe path.join(packagePath, 'node_modules', 'native-module')
|
||||
|
||||
it "utilizes _atomModuleCache to get native modules and skips traversing through submodules", ->
|
||||
it "utilizes _atomModuleCache if present to determine the package's native dependencies", ->
|
||||
packagePath = atom.project.getDirectories()[0]?.resolve('packages/package-with-ignored-incompatible-native-module')
|
||||
pack = new Package(packagePath)
|
||||
# Since `_atomModuleCache` exists and it doesn't have the record of the
|
||||
# incompatible native module, this package is recognized as compatible.
|
||||
expect(pack.getNativeModuleDependencyPaths().length).toBe(1) # doesn't see the incompatible module
|
||||
expect(pack.isCompatible()).toBe true
|
||||
|
||||
packagePath = atom.project.getDirectories()[0]?.resolve('packages/package-with-cached-incompatible-native-module')
|
||||
pack = new Package(packagePath)
|
||||
expect(pack.isCompatible()).toBe false
|
||||
|
||||
it "caches the incompatible native modules in local storage", ->
|
||||
packagePath = atom.project.getDirectories()[0]?.resolve('packages/package-with-incompatible-native-module')
|
||||
|
||||
|
@ -598,11 +598,10 @@ class Package
|
||||
nativeModulePaths = []
|
||||
|
||||
if @metadata._atomModuleCache?
|
||||
nativeModuleBindingPaths = @metadata._atomModuleCache.extensions?['.node'] ? []
|
||||
for nativeModuleBindingPath in nativeModuleBindingPaths
|
||||
# The `.node` file lies in nativeModulePath/build/Release/ folder.
|
||||
nativeModulePath = path.join(path.dirname(nativeModuleBindingPath), '..', '..')
|
||||
nativeModulePaths.push(nativeModulePath) if @isNativeModule(nativeModulePath)
|
||||
relativeNativeModuleBindingPaths = @metadata._atomModuleCache.extensions?['.node'] ? []
|
||||
for relativeNativeModuleBindingPath in relativeNativeModuleBindingPaths
|
||||
nativeModulePath = path.join(@path, relativeNativeModuleBindingPath, '..', '..', '..')
|
||||
nativeModulePaths.push(nativeModulePath)
|
||||
return nativeModulePaths
|
||||
|
||||
traversePath = (nodeModulesPath) =>
|
||||
|
Loading…
Reference in New Issue
Block a user