"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/edit.js" (8 Mar 2017, 886 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // npm edit <pkg>
    2 // open the package folder in the $EDITOR
    3 
    4 module.exports = edit
    5 edit.usage = 'npm edit <pkg>[@<version>]'
    6 
    7 edit.completion = require('./utils/completion/installed-shallow.js')
    8 
    9 var npm = require('./npm.js')
   10 var path = require('path')
   11 var fs = require('graceful-fs')
   12 var editor = require('editor')
   13 
   14 function edit (args, cb) {
   15   var p = args[0]
   16   if (args.length !== 1 || !p) return cb(edit.usage)
   17   var e = npm.config.get('editor')
   18   if (!e) {
   19     return cb(new Error(
   20       "No editor set.  Set the 'editor' config, or $EDITOR environ."
   21     ))
   22   }
   23   p = p.split('/')
   24        .join('/node_modules/')
   25        .replace(/(\/node_modules)+/, '/node_modules')
   26   var f = path.resolve(npm.dir, p)
   27   fs.lstat(f, function (er) {
   28     if (er) return cb(er)
   29     editor(f, { editor: e }, function (er) {
   30       if (er) return cb(er)
   31       npm.commands.rebuild(args, cb)
   32     })
   33   })
   34 }