Skip to content

Commit

Permalink
Meh 🤷
Browse files Browse the repository at this point in the history
  • Loading branch information
0x2b3bfa0 committed Sep 6, 2022
1 parent 1a48ffe commit aa48409
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion bin/cml/comment/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ exports.options = kebabcaseKeys({
update: {
type: 'boolean',
description:
'Update the last CML comment (if any) instead of creating a new one'
'Update the last CML comment (if any) instead of creating a new one',
hidden: true
},
rmWatermark: {
type: 'boolean',
Expand Down
2 changes: 0 additions & 2 deletions bin/cml/comment/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ describe('Comment integration tests', () => {
--native Uses driver's native capabilities to upload assets
instead of CML's storage; not available on GitHub
[boolean]
--update Update the last CML comment (if any) instead of
creating a new one [boolean]
--rm-watermark Avoid watermark; CML needs a watermark to be able to
distinguish CML comments from others [boolean]"
`);
Expand Down
10 changes: 10 additions & 0 deletions bin/cml/comment/update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { builder, handler } = require('./create');

exports.command = 'update <markdown file>';
exports.description = 'Update a comment';

exports.handler = async (opts) => {
await handler({ ...opts, update: true });
};

exports.builder = builder;
10 changes: 8 additions & 2 deletions src/cml.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,26 @@ class CML {
}

if (watch) {
let lock;
let first = true;
let lock = false;
watcher.add(triggerFile || markdownFile);
watcher.on('all', async (event, path) => {
if (lock) return;
lock = true;
try {
winston.info(`watcher event: ${event} ${path}`);
await this.commentCreate({ ...opts, update: true, watch: false });
await this.commentCreate({
...opts,
update: update || !first,
watch: false
});
if (event !== 'unlink' && path === triggerFile) {
await fs.unlink(triggerFile);
}
} catch (err) {
winston.warn(err);
}
first = false;
lock = false;
});
winston.info('watching for file changes...');
Expand Down

1 comment on commit aa48409

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

Please sign in to comment.