mithril-vndb/scripts/_upstream.js
Isiah Meadows 22e6d37a26 Refactor the scripts to work as advertised
- Correct docs generation to always fetch its dependency
- Don't try to close a handle that's already been closed by other methods
- Allow the release script to actually be testable.
2019-08-17 21:58:57 -04:00

35 lines
861 B
JavaScript

/* eslint-disable no-process-exit */
"use strict"
const {execFileSync} = require("child_process")
const remoteInfo = execFileSync("git", ["remote", "-v"], {
windowsHide: true,
stdio: ["inherit", "pipe", "inherit"],
encoding: "utf-8",
}).trim().split(/\r\n?|\n/g)
function find(type) {
const regexp = new RegExp(
"\t(?:" +
"(?:(?:git+)?https?|git|ssh)://(?:[^@\\s]+@)?github\\.com/|" +
"git@github\\.com:" +
")" +
`MithrilJS/mithril\\.js\\.git \\(${type}\\)$`
)
const line = remoteInfo.find((line) => regexp.test(line))
return line == null ? undefined : {
remote: line.slice(0, line.indexOf("\t")),
repo: line.slice(line.lastIndexOf("\t") + 1, -(type.length + 3)),
}
}
exports.fetch = find("fetch")
exports.push = find("push")
if (exports.fetch == null) {
console.error("You must have an upstream to pull from!")
process.exit(1)
}