Skip to content

Commit

Permalink
feat(collect-uncommitted): Remove figgy-pudding
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Nov 20, 2020
1 parent 45ee52e commit 621b382
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 0 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 17 additions & 9 deletions utils/collect-uncommitted/lib/collect-uncommitted.js
@@ -1,17 +1,17 @@
"use strict";

const chalk = require("chalk");
const figgyPudding = require("figgy-pudding");
const npmlog = require("npmlog");
const { exec, execSync } = require("@lerna/child-process");

module.exports = collectUncommitted;
module.exports.sync = sync;

const UncommittedConfig = figgyPudding({
cwd: {},
log: { default: npmlog },
});
/**
* @typedef {object} UncommittedConfig
* @property {string} cwd
* @property {typeof npmlog} [log]
*/

const maybeColorize = (colorize) => (s) => (s !== " " ? colorize(s) : s);
const cRed = maybeColorize(chalk.red);
Expand All @@ -30,15 +30,23 @@ const o = (l, r) => (x) => l(r(x));

const transformOutput = o(filterEmpty, o(splitOnNewLine, colorizeStats));

function collectUncommitted(options) {
const { cwd, log } = UncommittedConfig(options);
/**
* Report uncommitted files. (async)
* @param {UncommittedConfig} options
* @returns {Promise<string[]>} A list of uncommitted files
*/
function collectUncommitted({ cwd, log = npmlog }) {
log.silly("collect-uncommitted", "git status --porcelain (async)");

return exec("git", ["status", "--porcelain"], { cwd }).then(({ stdout }) => transformOutput(stdout));
}

function sync(options) {
const { cwd, log } = UncommittedConfig(options);
/**
* Report uncommitted files. (sync)
* @param {UncommittedConfig} options
* @returns {string[]} A list of uncommitted files
*/
function sync({ cwd, log = npmlog }) {
log.silly("collect-uncommitted", "git status --porcelain (sync)");

const stdout = execSync("git", ["status", "--porcelain"], { cwd });
Expand Down
1 change: 0 additions & 1 deletion utils/collect-uncommitted/package.json
Expand Up @@ -35,7 +35,6 @@
"dependencies": {
"@lerna/child-process": "file:../../core/child-process",
"chalk": "^4.1.0",
"figgy-pudding": "^3.5.1",
"npmlog": "^4.1.2"
}
}

0 comments on commit 621b382

Please sign in to comment.