"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/scripts/index-build.js" (11 Apr 2017, 1696 Bytes) of package /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 #!/usr/bin/env node
    2 var fs = require('fs')
    3 var path = require('path')
    4 var root = path.resolve(__dirname, '..')
    5 var glob = require('glob')
    6 var conversion = { 'cli': 1, 'api': 3, 'files': 5, 'misc': 7 }
    7 
    8 glob(root + '/{README.md,doc/*/*.md}', function (er, files) {
    9   if (er) throw er
   10 
   11   output(files.map(function (f) {
   12     var b = path.basename(f)
   13     if (b === 'README.md') return [0, b]
   14     if (b === 'index.md') return null
   15     var s = conversion[path.basename(path.dirname(f))]
   16     return [s, f]
   17   }).filter(function (f) {
   18     return f
   19   }).sort(function (a, b) {
   20     return (a[0] === b[0])
   21             ? (path.basename(a[1]) === 'npm.md' ? -1
   22             : path.basename(b[1]) === 'npm.md' ? 1
   23             : a[1] > b[1] ? 1 : -1)
   24             : a[0] - b[0]
   25   }))
   26 })
   27 
   28 function output (files) {
   29   console.log(
   30     'npm-index(7) -- Index of all npm documentation\n' +
   31     '==============================================\n')
   32 
   33   writeLines(files, 0)
   34   writeLines(files, 1, 'Command Line Documentation', 'Using npm on the command line')
   35   writeLines(files, 3, 'API Documentation', 'Using npm in your Node programs')
   36   writeLines(files, 5, 'Files', 'File system structures npm uses')
   37   writeLines(files, 7, 'Misc', 'Various other bits and bobs')
   38 }
   39 
   40 function writeLines (files, sxn, heading, desc) {
   41   if (heading) {
   42     console.log('## %s\n\n%s\n', heading, desc)
   43   }
   44   files.filter(function (f) {
   45     return f[0] === sxn
   46   }).forEach(writeLine)
   47 }
   48 
   49 function writeLine (sd) {
   50   var sxn = sd[0] || 1
   51   var doc = sd[1]
   52   var d = path.basename(doc, '.md')
   53 
   54   var content = fs.readFileSync(doc, 'utf8').split('\n')[0].split('-- ')[1]
   55 
   56   console.log('### %s(%d)\n', d, sxn)
   57   console.log(content + '\n')
   58 }