mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 11:22:19 +03:00
7f8ded6057
- `shellSync` was removed in execa v2 - this commit switches the usage to the recommended replacement; `sync` - also adds a test for changelog, the part of code which uses execa
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
const execa = require('execa');
|
|
const _ = require('lodash');
|
|
|
|
const localUtils = require('./utils');
|
|
|
|
class Changelog {
|
|
constructor(options = {}) {
|
|
localUtils.checkMissingOptions(options,
|
|
'folder',
|
|
'changelogPath'
|
|
);
|
|
|
|
this.changelogPath = options.changelogPath;
|
|
this.folder = options.folder;
|
|
}
|
|
|
|
write(options = {}) {
|
|
localUtils.checkMissingOptions(options,
|
|
'githubRepoPath',
|
|
'lastVersion'
|
|
);
|
|
|
|
let sign = '>';
|
|
|
|
if (options.append) {
|
|
sign = '>>';
|
|
}
|
|
|
|
const commands = [
|
|
`git log --no-merges --pretty=tformat:'%at * [%h](${options.githubRepoPath}/commit/%h) %s - %an' ${options.lastVersion}.. ${sign} ${this.changelogPath}`
|
|
];
|
|
|
|
_.each(commands, (command) => {
|
|
execa.sync(command, {cwd: options.folder || this.folder, shell: true});
|
|
});
|
|
|
|
return this;
|
|
}
|
|
|
|
sort() {
|
|
execa.sync(`sort -r ${this.changelogPath} -o ${this.changelogPath}`, {cwd: this.folder, shell: true});
|
|
|
|
return this;
|
|
}
|
|
|
|
clean() {
|
|
execa.sync(`sed -i.bk -E 's/^[0-9]{10} //g' ${this.changelogPath}`, {cwd: this.folder, shell: true});
|
|
|
|
return this;
|
|
}
|
|
}
|
|
|
|
module.exports = Changelog;
|