[Pkg-javascript-commits] [node-read-pkg-up] 01/03: Import Upstream version 2.0.0

Sruthi Chandran srud-guest at moszumanska.debian.org
Wed Nov 2 08:55:17 UTC 2016


This is an automated email from the git hooks/post-receive script.

srud-guest pushed a commit to branch master
in repository node-read-pkg-up.

commit 1321d156feb9986cab0d9202b49a9e0a185e5469
Author: Sruthi <srud at disroot.org>
Date:   Wed Nov 2 13:40:03 2016 +0530

    Import Upstream version 2.0.0
---
 .editorconfig    | 12 +++++++++
 .gitattributes   |  2 ++
 .gitignore       |  1 +
 .travis.yml      |  4 +++
 fixture/.gitkeep |  0
 index.js         | 26 ++++++++++++++++++
 license          | 21 +++++++++++++++
 package.json     | 62 +++++++++++++++++++++++++++++++++++++++++++
 readme.md        | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 test.js          | 18 +++++++++++++
 10 files changed, 226 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..98a761d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,12 @@
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[{package.json,*.yml}]
+indent_style = space
+indent_size = 2
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..391f0a4
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+* text=auto
+*.js text eol=lf
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..97519af
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+  - '6'
+  - '4'
diff --git a/fixture/.gitkeep b/fixture/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..2607976
--- /dev/null
+++ b/index.js
@@ -0,0 +1,26 @@
+'use strict';
+const findUp = require('find-up');
+const readPkg = require('read-pkg');
+
+module.exports = opts => {
+	return findUp('package.json', opts).then(fp => {
+		if (!fp) {
+			return {};
+		}
+
+		return readPkg(fp, opts).then(pkg => ({pkg, path: fp}));
+	});
+};
+
+module.exports.sync = opts => {
+	const fp = findUp.sync('package.json', opts);
+
+	if (!fp) {
+		return {};
+	}
+
+	return {
+		pkg: readPkg.sync(fp, opts),
+		path: fp
+	};
+};
diff --git a/license b/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus at gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..f09bf3c
--- /dev/null
+++ b/package.json
@@ -0,0 +1,62 @@
+{
+  "name": "read-pkg-up",
+  "version": "2.0.0",
+  "description": "Read the closest package.json file",
+  "license": "MIT",
+  "repository": "sindresorhus/read-pkg-up",
+  "author": {
+    "name": "Sindre Sorhus",
+    "email": "sindresorhus at gmail.com",
+    "url": "sindresorhus.com"
+  },
+  "engines": {
+    "node": ">=4"
+  },
+  "scripts": {
+    "test": "xo && ava"
+  },
+  "files": [
+    "index.js"
+  ],
+  "keywords": [
+    "json",
+    "read",
+    "parse",
+    "file",
+    "fs",
+    "graceful",
+    "load",
+    "pkg",
+    "package",
+    "find",
+    "up",
+    "find-up",
+    "findup",
+    "look-up",
+    "look",
+    "file",
+    "search",
+    "match",
+    "package",
+    "resolve",
+    "parent",
+    "parents",
+    "folder",
+    "directory",
+    "dir",
+    "walk",
+    "walking",
+    "path"
+  ],
+  "dependencies": {
+    "find-up": "^2.0.0",
+    "read-pkg": "^2.0.0"
+  },
+  "devDependencies": {
+    "ava": "*",
+    "xo": "*"
+  },
+  "xo": {
+    "esnext": true
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..ba18780
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,80 @@
+# read-pkg-up [![Build Status](https://travis-ci.org/sindresorhus/read-pkg-up.svg?branch=master)](https://travis-ci.org/sindresorhus/read-pkg-up)
+
+> Read the closest package.json file
+
+
+## Why
+
+- [Finds the closest package.json](https://github.com/sindresorhus/find-up)
+- [Gracefully handles filesystem issues](https://github.com/isaacs/node-graceful-fs)
+- [Strips UTF-8 BOM](https://github.com/sindresorhus/strip-bom)
+- [Throws more helpful JSON errors](https://github.com/sindresorhus/parse-json)
+- [Normalizes the data](https://github.com/npm/normalize-package-data#what-normalization-currently-entails)
+
+
+## Install
+
+```
+$ npm install --save read-pkg-up
+```
+
+
+## Usage
+
+```js
+const readPkgUp = require('read-pkg-up');
+
+readPkgUp().then(result => {
+	console.log(result);
+	/*
+	{
+		pkg: {
+			name: 'awesome-package',
+			version: '1.0.0',
+			...
+		},
+		path: '/Users/sindresorhus/dev/awesome-package/package.json'
+	}
+	*/
+});
+```
+
+
+## API
+
+### readPkgUp([options])
+
+Returns a `Promise` for the result object.
+
+### readPkgUp.sync([options])
+
+Returns the result object.
+
+#### options
+
+##### cwd
+
+Type: `string`<br>
+Default: `.`
+
+Directory to start looking for a package.json file.
+
+##### normalize
+
+Type: `boolean`<br>
+Default: `true`
+
+[Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.
+
+
+## Related
+
+- [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a package.json file
+- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
+- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
+- [pkg-conf](https://github.com/sindresorhus/pkg-conf) - Get namespaced config from the closest package.json
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..a35cc63
--- /dev/null
+++ b/test.js
@@ -0,0 +1,18 @@
+import path from 'path';
+import test from 'ava';
+import m from './';
+
+const cwd = 'fixture';
+const pkgPath = path.resolve('.', 'package.json');
+
+test('async', async t => {
+	const x = await m({cwd});
+	t.is(x.pkg.name, 'read-pkg-up');
+	t.is(x.path, pkgPath);
+});
+
+test('sync', t => {
+	const x = m.sync({cwd});
+	t.is(x.pkg.name, 'read-pkg-up');
+	t.is(x.path, pkgPath);
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-read-pkg-up.git



More information about the Pkg-javascript-commits mailing list