UNPKG

980 BJavaScriptView Raw
1/**
2 * @module read-package-json
3 * @author Toru Nagashima
4 * @copyright 2016 Toru Nagashima. All rights reserved.
5 * See LICENSE file in root directory for full license.
6 */
7"use strict"
8
9//------------------------------------------------------------------------------
10// Requirements
11//------------------------------------------------------------------------------
12
13const joinPath = require("path").join
14const readPkg = require("read-pkg")
15
16//------------------------------------------------------------------------------
17// Public Interface
18//------------------------------------------------------------------------------
19
20/**
21 * Reads the package.json in the current directory.
22 *
23 * @returns {object} package.json's information.
24 */
25module.exports = function readPackageJson() {
26 const path = joinPath(process.cwd(), "package.json")
27 return readPkg(path).then(body => ({
28 taskList: Object.keys(body.scripts || {}),
29 packageInfo: { path, body },
30 }))
31}