mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Merge branch 'stable' into beta
This commit is contained in:
commit
ef158cd23b
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"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
0
spec/fixtures/packages/package-with-ignored-incompatible-native-module/main.js
vendored
Normal file
0
spec/fixtures/packages/package-with-ignored-incompatible-native-module/main.js
vendored
Normal file
0
spec/fixtures/packages/package-with-ignored-incompatible-native-module/node_modules/compatible-native-module/main.js
generated
vendored
Normal file
0
spec/fixtures/packages/package-with-ignored-incompatible-native-module/node_modules/compatible-native-module/main.js
generated
vendored
Normal file
4
spec/fixtures/packages/package-with-ignored-incompatible-native-module/node_modules/compatible-native-module/package.json
generated
vendored
Normal file
4
spec/fixtures/packages/package-with-ignored-incompatible-native-module/node_modules/compatible-native-module/package.json
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "compatible-native-module",
|
||||
"main": "./main.js"
|
||||
}
|
0
spec/fixtures/packages/package-with-ignored-incompatible-native-module/node_modules/native-module/build/Release/native.node
generated
vendored
Normal file
0
spec/fixtures/packages/package-with-ignored-incompatible-native-module/node_modules/native-module/build/Release/native.node
generated
vendored
Normal file
1
spec/fixtures/packages/package-with-ignored-incompatible-native-module/node_modules/native-module/main.js
generated
vendored
Normal file
1
spec/fixtures/packages/package-with-ignored-incompatible-native-module/node_modules/native-module/main.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
throw new Error("this simulates a native module's failure to load")
|
4
spec/fixtures/packages/package-with-ignored-incompatible-native-module/node_modules/native-module/package.json
generated
vendored
Normal file
4
spec/fixtures/packages/package-with-ignored-incompatible-native-module/node_modules/native-module/package.json
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "native-module",
|
||||
"main": "./main.js"
|
||||
}
|
12
spec/fixtures/packages/package-with-ignored-incompatible-native-module/package.json
vendored
Normal file
12
spec/fixtures/packages/package-with-ignored-incompatible-native-module/package.json
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "package-with-ignored-incompatible-native-module",
|
||||
"version": "1.0.0",
|
||||
"main": "./main.js",
|
||||
"_atomModuleCache": {
|
||||
"extensions": {
|
||||
".node": [
|
||||
"node_modules/compatible-native-module/build/Release/native.node"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -19,6 +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 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)
|
||||
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')
|
||||
|
||||
|
@ -590,10 +590,20 @@ class Package
|
||||
false
|
||||
|
||||
# Get an array of all the native modules that this package depends on.
|
||||
# This will recurse through all dependencies.
|
||||
#
|
||||
# First try to get this information from
|
||||
# @metadata._atomModuleCache.extensions. If @metadata._atomModuleCache doesn't
|
||||
# exist, recurse through all dependencies.
|
||||
getNativeModuleDependencyPaths: ->
|
||||
nativeModulePaths = []
|
||||
|
||||
if @metadata._atomModuleCache?
|
||||
relativeNativeModuleBindingPaths = @metadata._atomModuleCache.extensions?['.node'] ? []
|
||||
for relativeNativeModuleBindingPath in relativeNativeModuleBindingPaths
|
||||
nativeModulePath = path.join(@path, relativeNativeModuleBindingPath, '..', '..', '..')
|
||||
nativeModulePaths.push(nativeModulePath)
|
||||
return nativeModulePaths
|
||||
|
||||
traversePath = (nodeModulesPath) =>
|
||||
try
|
||||
for modulePath in fs.listSync(nodeModulesPath)
|
||||
|
Loading…
Reference in New Issue
Block a user