-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): replace docs sh script with node
- Loading branch information
1 parent
fa91c4e
commit 11a339c
Showing
2 changed files
with
32 additions
and
27 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env node | ||
|
||
var fs = require('fs') | ||
var marked = require('marked-man') | ||
var npm = require('../lib/npm.js') | ||
var args = process.argv.slice(2) | ||
var src = args[0] | ||
var dest = args[1] || src | ||
|
||
fs.readFile(src, 'utf8', function (err, data) { | ||
if (err) return console.log(err) | ||
|
||
var fileExt = src.split('.').pop() | ||
var result = data.replace(/@VERSION@/g, npm.version) | ||
|
||
if (fileExt === 'md') { | ||
result = marked( | ||
result.replace(/\-\-\-([\s\S]+)\-\-\-/g, '') | ||
.replace(/(npm-)?([a-zA-Z\\\.\-]*)\(1\)/g, 'npm help $2') | ||
.replace(/(npm-)?([a-zA-Z\\\.\-]*)\((5|7)\)/g, 'npm help $2') | ||
.replace(/(npm-)?([a-zA-Z\\\.\-]*)\(3\)/g, 'npm apihelp $2') | ||
.replace(/npm(1)/g, 'npm help npm') | ||
.replace(/npm(3)/g, 'npm apihelp npm') | ||
.trim() | ||
) | ||
} | ||
|
||
fs.writeFile(dest, result, 'utf8', function (err) { | ||
if (err) return console.log(err) | ||
}) | ||
|
||
}) |