read-package-json.js 994 B

1234567891011121314151617181920212223242526272829303132
  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. const readPackage = require('read-package-json-fast')
  9. // ------------------------------------------------------------------------------
  10. // Requirements
  11. // ------------------------------------------------------------------------------
  12. const joinPath = require('path').join
  13. // ------------------------------------------------------------------------------
  14. // Public Interface
  15. // ------------------------------------------------------------------------------
  16. /**
  17. * Reads the package.json in the current directory.
  18. *
  19. * @returns {object} package.json's information.
  20. */
  21. module.exports = function readPackageJson () {
  22. const path = joinPath(process.cwd(), 'package.json')
  23. return readPackage(path).then(body => ({
  24. taskList: Object.keys(body.scripts || {}),
  25. packageInfo: { path, body },
  26. }))
  27. }