mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-18 16:03:37 +00:00
* refactor: list all commands in commands.json This also changes the order of commands in the docs, due to how I changed the doc-generating script. * fix lint error and alphabetize command list
36 lines
1.0 KiB
JavaScript
Executable File
36 lines
1.0 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
/* globals cat, cd, echo, grep, sed, ShellString */
|
|
require('../global');
|
|
|
|
echo('Appending docs to README.md');
|
|
|
|
cd(__dirname + '/..');
|
|
|
|
// Extract docs from shell.js
|
|
var docs = grep('^//@', 'shell.js');
|
|
|
|
// Insert the docs for all the registered commands
|
|
docs = docs.replace(/\/\/@commands\n/g, function () {
|
|
return require('../commands.json').map(function (commandName) {
|
|
var file = './src/' + commandName + '.js';
|
|
return grep('^//@', file) + '\n';
|
|
}).join('');
|
|
});
|
|
|
|
// Now extract docs from the remaining src/*.js files
|
|
docs = docs.replace(/\/\/@include (.+)/g, function (match, path) {
|
|
var file = path.match('.js$') ? path : path + '.js';
|
|
return grep('^//@', file);
|
|
});
|
|
|
|
// Remove '//@'
|
|
docs = docs.replace(/\/\/@ ?/g, '');
|
|
|
|
// Wipe out the old docs
|
|
ShellString(cat('README.md').replace(/## Command reference(.|\n)*\n## Team/, '## Command reference\n## Team')).to('README.md');
|
|
|
|
// Append new docs to README
|
|
sed('-i', /## Command reference/, '## Command reference\n\n' + docs, 'README.md');
|
|
|
|
echo('All done.');
|