Merge branch 'stable' into beta

This commit is contained in:
Nathan Sobo 2015-09-17 17:59:35 -06:00
commit ef158cd23b
12 changed files with 54 additions and 1 deletions

View 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"
]
}
}
}

View File

@ -0,0 +1,4 @@
{
"name": "compatible-native-module",
"main": "./main.js"
}

View File

@ -0,0 +1 @@
throw new Error("this simulates a native module's failure to load")

View File

@ -0,0 +1,4 @@
{
"name": "native-module",
"main": "./main.js"
}

View 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"
]
}
}
}

View File

@ -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')

View File

@ -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)