Clean up the oopsie. Rebuild the blank exercises.

This commit is contained in:
Michael Frank
2021-05-09 00:39:21 +12:00
parent b984cb4c6f
commit d28d80c46f
1565 changed files with 27186 additions and 199003 deletions
+31 -37
View File
@@ -1,47 +1,41 @@
'use strict';
const {promisify} = require('util');
const fs = require('fs');
const path = require('path');
const loadJsonFile = require('load-json-file');
const pathType = require('path-type');
const parseJson = require('parse-json');
module.exports = (fp, opts) => {
if (typeof fp !== 'string') {
opts = fp;
fp = '.';
const readFileAsync = promisify(fs.readFile);
module.exports = async options => {
options = {
cwd: process.cwd(),
normalize: true,
...options
};
const filePath = path.resolve(options.cwd, 'package.json');
const json = parseJson(await readFileAsync(filePath, 'utf8'));
if (options.normalize) {
require('normalize-package-data')(json);
}
opts = opts || {};
return pathType.dir(fp)
.then(isDir => {
if (isDir) {
fp = path.join(fp, 'package.json');
}
return loadJsonFile(fp);
})
.then(x => {
if (opts.normalize !== false) {
require('normalize-package-data')(x);
}
return x;
});
return json;
};
module.exports.sync = (fp, opts) => {
if (typeof fp !== 'string') {
opts = fp;
fp = '.';
module.exports.sync = options => {
options = {
cwd: process.cwd(),
normalize: true,
...options
};
const filePath = path.resolve(options.cwd, 'package.json');
const json = parseJson(fs.readFileSync(filePath, 'utf8'));
if (options.normalize) {
require('normalize-package-data')(json);
}
opts = opts || {};
fp = pathType.dirSync(fp) ? path.join(fp, 'package.json') : fp;
const x = loadJsonFile.sync(fp);
if (opts.normalize !== false) {
require('normalize-package-data')(x);
}
return x;
return json;
};
+4 -16
View File
@@ -1,21 +1,9 @@
The MIT License (MIT)
MIT License
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:
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 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.
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.
+25 -21
View File
@@ -1,27 +1,27 @@
{
"_from": "read-pkg@^2.0.0",
"_id": "read-pkg@2.0.0",
"_from": "read-pkg@^5.2.0",
"_id": "read-pkg@5.2.0",
"_inBundle": false,
"_integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=",
"_integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==",
"_location": "/read-pkg",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "read-pkg@^2.0.0",
"raw": "read-pkg@^5.2.0",
"name": "read-pkg",
"escapedName": "read-pkg",
"rawSpec": "^2.0.0",
"rawSpec": "^5.2.0",
"saveSpec": null,
"fetchSpec": "^2.0.0"
"fetchSpec": "^5.2.0"
},
"_requiredBy": [
"/read-pkg-up"
],
"_resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz",
"_shasum": "8ef1c0623c6a6db0dc6713c4bfac46332b2368f8",
"_spec": "read-pkg@^2.0.0",
"_where": "/Users/cloyd/coderrr/odin/javascript-exercises/node_modules/read-pkg-up",
"_resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz",
"_shasum": "7bf295438ca5a33e56cd30e053b34ee7250c93cc",
"_spec": "read-pkg@^5.2.0",
"_where": "/home/michael/projects/javascript-exercises/node_modules/read-pkg-up",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
@@ -32,21 +32,24 @@
},
"bundleDependencies": false,
"dependencies": {
"load-json-file": "^2.0.0",
"normalize-package-data": "^2.3.2",
"path-type": "^2.0.0"
"@types/normalize-package-data": "^2.4.0",
"normalize-package-data": "^2.5.0",
"parse-json": "^5.0.0",
"type-fest": "^0.6.0"
},
"deprecated": false,
"description": "Read a package.json file",
"devDependencies": {
"ava": "*",
"xo": "*"
"ava": "^2.2.0",
"tsd": "^0.7.2",
"xo": "^0.24.0"
},
"engines": {
"node": ">=4"
"node": ">=8"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"homepage": "https://github.com/sindresorhus/read-pkg#readme",
"keywords": [
@@ -57,7 +60,6 @@
"fs",
"graceful",
"load",
"pkg",
"package",
"normalize"
],
@@ -68,10 +70,12 @@
"url": "git+https://github.com/sindresorhus/read-pkg.git"
},
"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd"
},
"version": "2.0.0",
"version": "5.2.0",
"xo": {
"esnext": true
"ignores": [
"test/test.js"
]
}
}
+27 -25
View File
@@ -6,7 +6,6 @@
## Why
- [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)
@@ -14,7 +13,7 @@
## Install
```
$ npm install --save read-pkg
$ npm install read-pkg
```
@@ -23,41 +22,36 @@ $ npm install --save read-pkg
```js
const readPkg = require('read-pkg');
readPkg().then(pkg => {
console.log(pkg);
//=> {name: 'read-pkg', ...}
});
(async () => {
console.log(await readPkg());
//=> {name: 'read-pkg', }
readPkg(__dirname).then(pkg => {
console.log(pkg);
//=> {name: 'read-pkg', ...}
});
readPkg(path.join('unicorn', 'package.json')).then(pkg => {
console.log(pkg);
//=> {name: 'read-pkg', ...}
});
console.log(await readPkg({cwd: 'some-other-directory'}));
//=> {name: 'unicorn', …}
})();
```
## API
### readPkg([path], [options])
### readPkg(options?)
Returns a `Promise` for the parsed JSON.
Returns a `Promise<object>` with the parsed JSON.
### readPkg.sync([path], [options])
### readPkg.sync(options?)
Returns the parsed JSON.
#### path
#### options
Type: `object`
##### cwd
Type: `string`<br>
Default: `.`
Default: `process.cwd()`
Path to a `package.json` file or its directory.
#### options
Current working directory.
##### normalize
@@ -74,6 +68,14 @@ Default: `true`
- [load-json-file](https://github.com/sindresorhus/load-json-file) - Read and parse a JSON file
## License
---
MIT © [Sindre Sorhus](https://sindresorhus.com)
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-read-pkg?utm_source=npm-read-pkg&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>