🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

noda

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

noda - npm Package Compare versions

Comparing version
0.4.0
to
0.5.0
+34
packageOf.js
'use strict';
const MODULE_REQUIRE = 1
/* built-in */
, fs = require('fs')
, path = require('path')
/* NPM */
/* in-package */
;
let packageOf = function(id, mod) {
let packageJson = null;
let pathname = require.resolve(id, mod.paths);
let dirname = fs.statSync(pathname).isDirectory() ? pathname : path.dirname(pathname);
do {
let packageJsonPath = path.join(dirname, 'package.json');
if (fs.existsSync(packageJsonPath)) {
packageJson = require(packageJsonPath);
break;
}
if (dirname == (dirname = path.dirname(dirname))) {
throw new Error('package.json not found');
}
} while(1);
return packageJson;
};
module.exports = packageOf;
+6
-0

@@ -5,2 +5,8 @@ # noda Change Log

## [0.5.0] - May 13th, 2018
* `noda.packageOf()` added.
* `noda.packageRoot()` added.
* `noda.inResolve()` updated to accept more arguments as `path.resolve()` does.
## [0.4.0] - April 1st, 2018 - BETA

@@ -7,0 +13,0 @@

+12
-5

@@ -161,7 +161,6 @@ /**

*/
let inResolve = (subpath) => {
let inResolve = function(...subpath) {
// Find home directory of the package in which the caller is located.
let dirname = getCallerPackageDir();
return path.join(dirname, subpath);
return path.join.apply(path, [ dirname ].concat(subpath));
};

@@ -341,5 +340,13 @@

/**
* Return the root path of current package.
*/
let packageRoot = function() {
return inResolve('.');
};
module.exports = {
bindings: require('./bindings'),
packageOf: require('./packageOf'),
currentPackage,

@@ -360,3 +367,3 @@ inExists,

downResolve,
'existsInPackage': inExists,

@@ -363,0 +370,0 @@ 'readInPackage': inRead,

{
"name": "noda",
"version": "0.4.0",
"version": "0.5.0",
"description": "NOde Developing Assistant",

@@ -10,3 +10,5 @@ "main": "index.js",

"keywords": [
"bindings",
"require",
"require-addon",
"require-all",

@@ -13,0 +15,0 @@ "package-homepath"

@@ -47,2 +47,5 @@ # noda

* __noda.packageOf__(string *id*, Object *module*)
Return the object parsed from package.json which belongs to the special package named *id* according to the view angle of special *module*.
* __noda.currentPackage__()

@@ -88,15 +91,15 @@ Return the object parsed from package.json which belongs to current package.

* __noda.existsInPackage__
* __noda.existsInPackage__
Alias of `noda.inExists`.
* __noda.readInPackage__
* __noda.readInPackage__
Alias of `noda.inRead`.
* __noda.requireInPackage__
* __noda.requireInPackage__
Alias of `noda.inRequire`.
* __noda.requireDirInPackage__
* __noda.requireDirInPackage__
Alias of `noda.inRequireDir`.
* __noda.resolveInPackage__
* __noda.resolveInPackage__
Alias of `noda.inResolve`.

@@ -103,0 +106,0 @@