Comparing version 0.3.1 to 0.3.2
31
index.js
var deprecate = require('util').deprecate; | ||
var version = process.version; | ||
var _isIo = parseInt(version.match(/^v(\d+)\./)[1]) >= 1; | ||
var isIojs = parseInt(version.match(/^v(\d+)\./)[1]) >= 1; | ||
var reliableCheck = null; | ||
module.exports = function() { | ||
return _isIo; | ||
return isIojs; | ||
}; | ||
var safeCheck = null; | ||
module.exports.reliable = function() { | ||
if (safeCheck) { | ||
return safeCheck; | ||
} | ||
var isIo = _isIo; | ||
if (reliableCheck) return reliableCheck; | ||
if (isIo && !~['v1.0.0','v1.0.1'].indexOf(version)) { | ||
var _isIojs = isIojs; | ||
if (isIojs && !~['v1.0.0','v1.0.1'].indexOf(version)) { | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var exec = require('child_process').exec; | ||
var temp = require('os').tmpdir(); | ||
var helpFile = path.join(process.cwd(), '.is-iojs-help-ey4Be6vDPrGfXGey4Be6vDPrGfXG'); | ||
var doneFile = path.join(process.cwd(), '.is-iojs-done-ey4Be6vDPrGfXGey4Be6vDPrGfXG'); | ||
var execPath = process.execPath; | ||
var helpFile = path.join(temp, 'is-iojs-help-ey4Be6vDPrGfXGey4Be6vDPrGfXG'); | ||
var doneFile = path.join(temp, 'is-iojs-done-ey4Be6vDPrGfXGey4Be6vDPrGfXG'); | ||
exec(execPath + ' -h > ' + helpFile + '&& echo "done" > ' + doneFile); | ||
exec(process.execPath + ' -h > ' + helpFile + '&& echo "done" > ' + doneFile); | ||
while (!fs.existsSync(doneFile)) {} | ||
var helpMessage = fs.readFileSync(helpFile, { encoding: 'ascii' }); | ||
isIo = /iojs\.org/.test(helpMessage); | ||
_isIojs = /iojs\.org/.test(fs.readFileSync(helpFile, { encoding: 'ascii' })); | ||
@@ -37,7 +34,5 @@ fs.unlinkSync(helpFile); | ||
return safeCheck = function() { | ||
return isIo; | ||
}; | ||
return reliableCheck = function() { return _isIojs }; | ||
}; | ||
module.exports.safe = deprecate(module.exports.reliable, '.safe() method is deprecated. Use .reliable() instead of it.'); |
{ | ||
"name": "is-iojs", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Determines if runtime is iojs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24004
26