Comparing version 0.2.1 to 0.2.2-rc1
@@ -17,3 +17,3 @@ 'use strict'; | ||
var createJqCommand = function createJqCommand(filter, json) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -29,3 +29,3 @@ var command = { | ||
var run = exports.run = function run(filter, json) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -32,0 +32,0 @@ return new Promise(function (resolve, reject) { |
@@ -40,3 +40,3 @@ 'use strict'; | ||
var mergeOptionDefaults = function mergeOptionDefaults() { | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -51,3 +51,3 @@ Object.keys(optionDefaults).forEach(function (key) { | ||
var parseOptions = exports.parseOptions = function parseOptions(filter, json) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
@@ -54,0 +54,0 @@ mergeOptionDefaults(options); |
{ | ||
"name": "node-jq", | ||
"version": "0.2.1", | ||
"version": "0.2.2-rc1", | ||
"description": "Run jq in node", | ||
@@ -5,0 +5,0 @@ "main": "lib/jq.js", |
@@ -76,5 +76,37 @@ #!/usr/bin/env node | ||
/** | ||
* Finds the pathname of the parent module's package descriptor file. If the | ||
* directory is undefined (the default case), then it is set to the directory | ||
* name of the parent module's filename. If no package.json file is found, then | ||
* the parent directories are recursively searched until the file is found or | ||
* the root directory is reached. Returns the pathname if found or null if not. | ||
*/ | ||
function findParentPackage (directory) { | ||
if (!directory) { | ||
directory = path.dirname(module.parent.filename) | ||
} | ||
const file = path.resolve(directory, 'package.json') | ||
if (fs.existsSync(file) && fs.statSync(file).isFile()) { | ||
return file | ||
} | ||
const parent = path.resolve(directory, '..') | ||
if (parent === directory) { | ||
return null | ||
} | ||
return findParentPackage(parent) | ||
} | ||
function saveAndRenameToJq (data) { | ||
console.log('Done!') | ||
return fs.writeFile(BINARY_PATH + 'jq', data, { mode: 0o777, encoding: 'binary' }) | ||
let binaryPath | ||
try { | ||
binaryPath = findParentPackage() | ||
} catch (e) { | ||
binaryPath = BINARY_PATH | ||
} | ||
return fs.writeFile(binaryPath + 'jq', data, { mode: 0o777, encoding: 'binary' }) | ||
} | ||
@@ -81,0 +113,0 @@ |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
17674
12
394
0
66