frontend/.pnpm-store/v3/files/6c/609576e06a52b81ca9cd2236e349a9d3600ca74084ed4df8fcff90cec269e96de650f1e6ff52c493e896c49359e44f168509c786e39a1db152c56d894853a1

30 lines
770 B
Plaintext

const fs = require('fs').promises;
const path = require('path');
const sh = require('shelljs');
const tmp = require('tmp');
const mkTmpDir = () => {
const dir = tmp.dirSync({ prefix: 'release-it-' });
return dir.name;
};
const readFile = file => fs.readFile(path.resolve(file), 'utf8');
const gitAdd = (content, file, message) => {
sh.ShellString(content).toEnd(file);
sh.exec(`git add ${file}`);
const { stdout } = sh.exec(`git commit -m "${message}"`);
const match = stdout.match(/\[.+([a-z0-9]{7})\]/);
return match ? match[1] : null;
};
const getArgs = (args, prefix) =>
args.filter(args => typeof args[0] === 'string' && args[0].startsWith(prefix)).map(args => args[0].trim());
module.exports = {
mkTmpDir,
readFile,
gitAdd,
getArgs
};