launch.js 486 B

12345678910111213141516
  1. const launch = require('launch-editor')
  2. exports.launch = (...args) => {
  3. const file = args[0]
  4. console.log(`Opening ${file}...`)
  5. let cb = args[args.length - 1]
  6. if (typeof cb !== 'function') {
  7. cb = null
  8. }
  9. launch(...args, (fileName, errorMessage) => {
  10. console.error(`Unable to open '${fileName}'`, errorMessage)
  11. console.log(`Try setting the EDITOR env variable. More info: https://github.com/yyx990803/launch-editor`)
  12. if (cb) cb(fileName, errorMessage)
  13. })
  14. }