Skip to content

Commit 7c63a5c

Browse files
Fix [object Object] is not a future
When ios-sim-portable is used as dependency of any module that has fibers, the fibers in ios-sim-portable conflict at runtime with the original package's fibers. So add postinstall script to check if there are fibers in the upper level dir and upper level dir is called node_modules. If these circumstances are fulfilled, remove the ios-sim-portable's fibers directory - let's use original package's fibers module.
1 parent 09c2acd commit 7c63a5c

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "ios-sim-portable",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "",
55
"main": "./lib/ios-sim.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"prepublish": "node prepublish.js"
8+
"prepublish": "node prepublish.js",
9+
"postinstall": "node postinstall.js"
910
},
1011
"bin": {
1112
"ios-sim-portable": "./bin/ios-sim-portable.js",
@@ -33,7 +34,8 @@
3334
"nodobjc": "https://github.com/telerik/NodObjC/tarball/v2.0.0.2",
3435
"osenv": "0.1.3",
3536
"plist": "1.1.0",
36-
"yargs": "3.15.0"
37+
"shelljs": "0.7.0",
38+
"yargs": "4.7.1"
3739
},
3840
"devDependencies": {
3941
"grunt-contrib-clean": "0.6.0",

postinstall.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"use strict";
2+
3+
var shelljs = require("shelljs"),
4+
fs = require("fs"),
5+
path = require("path"),
6+
fibersDirName = "fibers",
7+
nodeModulesDirName = "node_modules";
8+
9+
try {
10+
// In case there are fibers in upper level's node_modules dir, we should remove iOSSimPortable's fibers module.
11+
var pathToUpperLevelNodeModulesDir = path.join(__dirname, ".."),
12+
pathToUpperLevelFibersDir = path.join(pathToUpperLevelNodeModulesDir, fibersDirName);
13+
14+
var nodeModulesStat = fs.statSync(pathToUpperLevelNodeModulesDir),
15+
fibersStat = fs.statSync(pathToUpperLevelFibersDir);
16+
17+
if (nodeModulesStat.isDirectory() && path.basename(pathToUpperLevelNodeModulesDir) === nodeModulesDirName && fibersStat.isDirectory()) {
18+
shelljs.rm("-rf", path.join(__dirname, nodeModulesDirName, fibersDirName));
19+
}
20+
} catch (err) {
21+
// Ignore the error. Most probably ios-sim-portable is not used as dependency, so we should not delete anything.
22+
}

0 commit comments

Comments
 (0)