documentary
Advanced tools
Comparing version 1.8.2 to 1.9.0
@@ -12,2 +12,4 @@ #!/usr/bin/env node | ||
var _spawncommand = _interopRequireDefault(require("spawncommand")); | ||
var _run = _interopRequireDefault(require("./run")); | ||
@@ -23,3 +25,4 @@ | ||
toc: _toc, | ||
watch: _watch | ||
watch: _watch, | ||
push: _push | ||
} = (0, _argufy.default)({ | ||
@@ -37,5 +40,13 @@ source: { | ||
}, | ||
output: 'o' | ||
output: 'o', | ||
push: { | ||
short: 'p' | ||
} | ||
}); | ||
if (process.argv.find(a => a == '-p') && !_push) { | ||
console.log('Please specify a commit message.'); | ||
process.exit(1); | ||
} | ||
const doc = async (source, output, justToc = false) => { | ||
@@ -78,3 +89,3 @@ if (!source) { | ||
if (_watch) { | ||
if (_watch || _push) { | ||
(0, _fs.watch)(_source, { | ||
@@ -86,2 +97,8 @@ recursive: true | ||
await doc(_source, _output, _toc); | ||
if (_push) { | ||
console.log('Pushing documentation changes'); | ||
await gitPush(_source, _output, _push); | ||
} | ||
setTimeout(() => { | ||
@@ -94,2 +111,29 @@ debounce = false; | ||
})(); | ||
const gitPush = async (source, output, message) => { | ||
const { | ||
promise | ||
} = (0, _spawncommand.default)('git', ['log', '--format=%B', '-n', '1']); | ||
const { | ||
stdout | ||
} = await promise; | ||
const s = stdout.trim(); | ||
if (s == message) { | ||
await git('reset', 'HEAD~1'); | ||
} | ||
await git('add', source, output); | ||
await git('commit', '-m', message); | ||
await git('push', '-f'); | ||
}; | ||
const git = async (...args) => { | ||
const { | ||
promise | ||
} = (0, _spawncommand.default)('git', args, { | ||
stdio: 'inherit' | ||
}); | ||
await promise; | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -18,12 +18,18 @@ "use strict"; | ||
const replaceFile = (stream, toc, out) => { | ||
const s = (0, _replaceStream.default)(toc); | ||
const ws = out ? (0, _fs.createWriteStream)(out) : process.stdout; | ||
stream.pipe(s).pipe(ws); | ||
const replaceFile = async (stream, toc, out) => { | ||
await new Promise((r, j) => { | ||
const s = (0, _replaceStream.default)(toc); | ||
const ws = out ? (0, _fs.createWriteStream)(out) : process.stdout; | ||
stream.pipe(s).pipe(ws); | ||
if (out) { | ||
ws.on('close', () => { | ||
console.log('Saved %s', out); | ||
}); | ||
} | ||
if (out) { | ||
ws.on('close', () => { | ||
console.log('Saved %s', out); | ||
r(); | ||
}); | ||
ws.on('error', j); | ||
} else { | ||
r(); | ||
} | ||
}); | ||
}; | ||
@@ -49,4 +55,4 @@ /** | ||
pt.resume(); | ||
replaceFile(pt, t, out); | ||
await replaceFile(pt, t, out); | ||
} | ||
//# sourceMappingURL=run.js.map |
@@ -0,1 +1,7 @@ | ||
## 17 July 2018 | ||
### 1.9.0 | ||
- [feature] Automatic `git` push during watch with `-p` argument. | ||
## 3 July 2018 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "documentary", | ||
"version": "1.8.2", | ||
"version": "1.9.0", | ||
"description": "A library to manage documentation, such as README, usage, man pages and changelog.", | ||
@@ -16,6 +16,3 @@ "main": "build", | ||
"d": "yarn-s doc_add doc_commit doc_push", | ||
"doc_add": "git add documentation README.md", | ||
"doc_commit": "git commit -m doc", | ||
"doc_push": "git push", | ||
"doc": "yarn dev documentation -o README.md", | ||
"doc": "yarn dev documentary -o README.md", | ||
"start": "node build/bin", | ||
@@ -22,0 +19,0 @@ "example/": "yarn e example/example.js", |
@@ -35,2 +35,7 @@ # documentary | ||
- [CLI](#cli) | ||
* [Output Location](#output-location) | ||
* [Only TOC](#only-toc) | ||
* [Watch Mode](#watch-mode) | ||
* [Automatic Push](#automatic-push) | ||
* [`NODE_DEBUG=doc`](#node_debugdoc) | ||
- [API](#api) | ||
@@ -160,3 +165,3 @@ * [`Toc` Stream](#toc-stream) | ||
```m | ||
documentation | ||
documentary | ||
├── 1-installation-and-usage | ||
@@ -387,9 +392,10 @@ │ ├── 1-vs-code.md | ||
| argument | Description | | ||
| -------- | ----------- | | ||
| `-o` | Where to save the processed `README` file. If not specified, the output is written to the `stdout`. | | ||
| `-t` | Only extract and print the table of contents. | | ||
| `-w` | Watch mode: re-run the program when changes to the source file are detected. | | ||
| Flag | Meaning | Description | | ||
| ---- | ------- | ----------- | | ||
| `-o` | <a name="output-location">Output Location</a> | Where to save the processed `README` file. If not specified, the output is written to the `stdout`. | | ||
| `-t` | <a name="only-toc">Only TOC</a> | Only extract and print the table of contents. | | ||
| `-w` | <a name="watch-mode">Watch Mode</a> | Watch mode: re-run the program when changes to the source file are detected. | | ||
| `-p` | <a name="automatic-push">Automatic Push</a> | Watch + push: automatically push changes to a remote git branch by squashing them into a single commit. | | ||
When `NODE_DEBUG=doc` is set, the program will print debug information, e.g., | ||
When <a name="node_debugdoc">`NODE_DEBUG=doc`</a> is set, the program will print debug information, e.g., | ||
@@ -491,4 +497,4 @@ ``` | ||
(c) [Art Deco Code][1] 2018 | ||
(c) [Art Deco][1] 2018 | ||
[1]: https://artdeco.bz |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
96554
945
497