aboutsummaryrefslogtreecommitdiff
path: root/node_modules/write-pkg
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-28 00:38:50 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-28 00:40:43 +0200
commit7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (patch)
tree6de9a1aebd150a23b7f8c273ec657a5d0a18fe3e /node_modules/write-pkg
parent963b7a41feb29cc4be090a2446bdfe0c1f1bcd81 (diff)
downloadwallet-core-7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027.tar.xz
add linting (and some initial fixes)
Diffstat (limited to 'node_modules/write-pkg')
-rw-r--r--node_modules/write-pkg/index.js49
-rw-r--r--node_modules/write-pkg/license21
-rw-r--r--node_modules/write-pkg/package.json41
-rw-r--r--node_modules/write-pkg/readme.md59
4 files changed, 170 insertions, 0 deletions
diff --git a/node_modules/write-pkg/index.js b/node_modules/write-pkg/index.js
new file mode 100644
index 000000000..262fa925a
--- /dev/null
+++ b/node_modules/write-pkg/index.js
@@ -0,0 +1,49 @@
+'use strict';
+const path = require('path');
+const writeJsonFile = require('write-json-file');
+const sortKeys = require('sort-keys');
+
+const opts = {indent: 2};
+
+const dependencyKeys = new Set([
+ 'dependencies',
+ 'devDependencies',
+ 'optionalDependencies',
+ 'peerDependencies'
+]);
+
+function normalize(pkg) {
+ const ret = {};
+
+ for (const key of Object.keys(pkg)) {
+ ret[key] = dependencyKeys.has(key) ? sortKeys(pkg[key]) : pkg[key];
+ }
+
+ return ret;
+}
+
+module.exports = (fp, data) => {
+ if (typeof fp !== 'string') {
+ data = fp;
+ fp = '.';
+ }
+
+ fp = path.basename(fp) === 'package.json' ? fp : path.join(fp, 'package.json');
+
+ data = normalize(data);
+
+ return writeJsonFile(fp, data, opts);
+};
+
+module.exports.sync = (fp, data) => {
+ if (typeof fp !== 'string') {
+ data = fp;
+ fp = '.';
+ }
+
+ fp = path.basename(fp) === 'package.json' ? fp : path.join(fp, 'package.json');
+
+ data = normalize(data);
+
+ writeJsonFile.sync(fp, data, opts);
+};
diff --git a/node_modules/write-pkg/license b/node_modules/write-pkg/license
new file mode 100644
index 000000000..654d0bfe9
--- /dev/null
+++ b/node_modules/write-pkg/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus@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/node_modules/write-pkg/package.json b/node_modules/write-pkg/package.json
new file mode 100644
index 000000000..c3773513c
--- /dev/null
+++ b/node_modules/write-pkg/package.json
@@ -0,0 +1,41 @@
+{
+ "name": "write-pkg",
+ "version": "2.1.0",
+ "description": "Write a package.json file",
+ "license": "MIT",
+ "repository": "sindresorhus/write-pkg",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "json",
+ "write",
+ "stringify",
+ "file",
+ "fs",
+ "graceful",
+ "pkg",
+ "package"
+ ],
+ "dependencies": {
+ "sort-keys": "^1.1.2",
+ "write-json-file": "^2.0.0"
+ },
+ "devDependencies": {
+ "ava": "*",
+ "read-pkg": "^2.0.0",
+ "tempfile": "^1.1.1",
+ "xo": "*"
+ }
+}
diff --git a/node_modules/write-pkg/readme.md b/node_modules/write-pkg/readme.md
new file mode 100644
index 000000000..fa51dad26
--- /dev/null
+++ b/node_modules/write-pkg/readme.md
@@ -0,0 +1,59 @@
+# write-pkg [![Build Status](https://travis-ci.org/sindresorhus/write-pkg.svg?branch=master)](https://travis-ci.org/sindresorhus/write-pkg)
+
+> Write a `package.json` file
+
+Writes atomically and creates directories for you as needed. Sorts dependencies when writing.
+
+
+## Install
+
+```
+$ npm install --save write-pkg
+```
+
+
+## Usage
+
+```js
+const path = require('path');
+const writePkg = require('write-pkg');
+
+writePkg({foo: true}).then(() => {
+ console.log('done');
+});
+
+writePkg(__dirname, {foo: true}).then(() => {
+ console.log('done');
+});
+
+writePkg(path.join('unicorn', 'package.json'), {foo: true}).then(() => {
+ console.log('done');
+});
+```
+
+
+## API
+
+### writePkg([path], data)
+
+Returns a `Promise`.
+
+### writePkg.sync([path], data)
+
+#### path
+
+Type: `string`<br>
+Default: `process.cwd()`
+
+Path to where the `package.json` file should be written or its directory.
+
+
+## Related
+
+- [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a `package.json` file
+- [write-json-file](https://github.com/sindresorhus/write-json-file) - Stringify and write JSON to a file atomically
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)