mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: support hydrooj patch
This commit is contained in:
4 files changed
+55
-1
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import child from 'child_process';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import superagent from 'superagent';
|
||||
|
||||
if (!process.argv[2]) throw new Error('No target specified');
|
||||
|
||||
// TODO support module other than packages
|
||||
const target = process.argv[2].startsWith('packages/') ? process.argv[2] : `packages/${process.argv[2]}`;
|
||||
|
||||
const result = child.execSync(`git diff ${target}`);
|
||||
const patch = result.toString().replace(new RegExp(`${target}/`, 'g'), '');
|
||||
const filename = `${path.basename(target)}.patch`;
|
||||
fs.writeFileSync(filename, patch);
|
||||
superagent.post('https://hydro.ac/paste')
|
||||
.set('accept', 'application/json')
|
||||
.send({ body: patch, filename })
|
||||
.end((err, res) => {
|
||||
if (err) throw err;
|
||||
console.log('Paste created on ', res.text);
|
||||
});
|
||||
Reference in new issue
Block a user