-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
read-package-json.js
32 lines (27 loc) · 993 Bytes
/
read-package-json.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* @module read-package-json
* @author Toru Nagashima
* @copyright 2016 Toru Nagashima. All rights reserved.
* See LICENSE file in root directory for full license.
*/
'use strict'
const readPackage = require('read-package-json-fast')
// ------------------------------------------------------------------------------
// Requirements
// ------------------------------------------------------------------------------
const joinPath = require('path').join
// ------------------------------------------------------------------------------
// Public Interface
// ------------------------------------------------------------------------------
/**
* Reads the package.json in the current directory.
*
* @returns {object} package.json's information.
*/
module.exports = function readPackageJson () {
const path = joinPath(process.cwd(), 'package.json')
return readPackage(path).then(body => ({
taskList: Object.keys(body.scripts || {}),
packageInfo: { path, body }
}))
}