Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abandoned files work #432

Merged
merged 12 commits into from
Jan 27, 2025
Prev Previous commit
Next Next commit
. t the command line test now runs in a temp directory
ilandikov committed Jan 27, 2025
commit 573e75dc4c67f01135003631f6d56dc11f2fe4be
14 changes: 12 additions & 2 deletions test/commandLineTests.mts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import shelljs from "shelljs";
import path from "path";
import fs from "fs";
import * as os from "node:os";

describe("Command Line", function () {
it("Should run approvals CLI with basic text input", function (done) {
// get the absolute path for ./
// const pwd = process.cwd();
const pwd = '/Users/il/Documents/git/Approvals.NodeJS';
var cliTestCommand =
'echo "Hello\nWorld" | ' +
path.join("./", "bin", "index.js") +
" --reporter gitdiff --errorOnStaleApprovedFiles=false --outdir ./test commandlineTest";
path.join(pwd, "/", "bin", "index.js") +
" --reporter gitdiff --errorOnStaleApprovedFiles=false --outdir "+ pwd + "/test commandlineTest";

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'example-'));
process.chdir(tempDir);

shelljs.exec(cliTestCommand, { async: true }, function (code, output) {
if (code !== 0) {
@@ -15,5 +23,7 @@ describe("Command Line", function () {
}
done();
});

process.chdir(pwd);
});
});