You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hydro/build/gen-patch.ts

22 lines
778 B
TypeScript

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);
});