Skip to content

Commit

Permalink
Try fixing all inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
banga committed Dec 31, 2023
1 parent 1da6aa9 commit 00cb4d2
Showing 1 changed file with 35 additions and 21 deletions.
56 changes: 35 additions & 21 deletions test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spawnSync } from 'child_process';
import assert from 'assert';
import { spawnSync } from 'child_process';

async function main() {
const input = `
Expand All @@ -19,30 +19,44 @@ index 0000000..c72d334
+package-lock.json -diff
+yarn.lock -diff
`;
const expected =
'\n' +
'\x1B[48;2;43;43;43m\x1B[38;2;136;192;208mcommit\x1B[39m\x1B[49m\x1B[48;2;43;43;43m\x1B[38;2;191;97;106m e250bec66b6c39d4c2f9e0e52a18245f16a7195a \x1B[39m\x1B[49m\x1B[48;2;43;43;43m\x1B[38;2;76;86;106m \x1B[39m\x1B[49m\n' +
'\x1B[48;2;43;43;43m\x1B[38;2;136;192;208mAuthor:\x1B[39m\x1B[49m\x1B[48;2;43;43;43m\x1B[38;2;208;135;112m Shrey Banga <banga.shrey@gmail.com> \x1B[39m\x1B[49m\x1B[48;2;43;43;43m\x1B[38;2;76;86;106m \x1B[39m\x1B[49m\n' +
'\x1B[48;2;43;43;43m\x1B[38;2;136;192;208mDate:\x1B[39m\x1B[49m\x1B[48;2;43;43;43m\x1B[38;2;235;203;139m Fri Dec 29 11:14:25 2023 -0500 \x1B[39m\x1B[49m\x1B[48;2;43;43;43m\x1B[38;2;76;86;106m \x1B[39m\x1B[49m\n' +
'\x1B[48;2;43;43;43m\x1B[38;2;76;86;106m \x1B[39m\x1B[49m\n' +
'\x1B[48;2;43;43;43m\x1B[38;2;236;239;244m Exclude lockfiles from diffs\x1B[39m\x1B[49m\x1B[48;2;43;43;43m\x1B[38;2;216;222;233m \x1B[39m\x1B[49m\n' +
'\x1B[48;2;43;43;43m\x1B[38;2;216;222;233m \x1B[39m\x1B[49m\n' +
'\x1B[48;2;43;43;43m\x1B[38;2;235;203;139m────────────────────────────────────────────────────────────────────────────────\x1B[39m\x1B[49m\n' +
'\x1B[48;2;43;43;43m\x1B[38;2;235;203;139m \x1B[39m\x1B[49m\x1B[48;2;48;58;53m\x1B[38;2;163;190;140m■■\x1B[39m\x1B[49m\x1B[48;2;43;43;43m\x1B[38;2;235;203;139m .gitattributes \x1B[39m\x1B[49m\n' +
'\x1B[48;2;43;43;43m\x1B[38;2;235;203;139m────────────────────────────────────────────────────────────────────────────────\x1B[39m\x1B[49m\n' +
'\x1B[48;2;43;43;43m\x1B[38;2;76;86;106m@@ -0,0 +1,3 @@ \x1B[39m\x1B[49m\n' +
'\x1B[48;2;46;52;64m\x1B[38;2;229;233;240m \x1B[39m\x1B[49m\x1B[48;2;48;58;53m\x1B[38;2;163;190;140m 1 \x1B[39m\x1B[49m\x1B[48;2;48;58;53m\x1B[38;2;163;190;140m + # exclude lock files from git \x1B[39m\x1B[49m\n' +
'\x1B[48;2;46;52;64m\x1B[38;2;229;233;240m \x1B[39m\x1B[49m\x1B[48;2;48;58;53m\x1B[38;2;163;190;140m \x1B[39m\x1B[49m\x1B[48;2;48;58;53m\x1B[38;2;163;190;140m diff \x1B[39m\x1B[49m\n' +
'\x1B[48;2;46;52;64m\x1B[38;2;229;233;240m \x1B[39m\x1B[49m\x1B[48;2;48;58;53m\x1B[38;2;163;190;140m 2 \x1B[39m\x1B[49m\x1B[48;2;48;58;53m\x1B[38;2;163;190;140m + package-lock.json -diff \x1B[39m\x1B[49m\n' +
'\x1B[48;2;46;52;64m\x1B[38;2;229;233;240m \x1B[39m\x1B[49m\x1B[48;2;48;58;53m\x1B[38;2;163;190;140m 3 \x1B[39m\x1B[49m\x1B[48;2;48;58;53m\x1B[38;2;163;190;140m + yarn.lock -diff \x1B[39m\x1B[49m\n' +
'\x1B[48;2;46;52;64m\x1B[38;2;229;233;240m \x1B[39m\x1B[49m\x1B[48;2;43;43;43m\x1B[38;2;76;86;106m 4 \x1B[39m\x1B[49m\x1B[48;2;43;43;43m\x1B[38;2;229;233;240m \x1B[39m\x1B[49m\n';
const { stdout, stderr } = spawnSync(
/* Generated with:
stty cols 80 &&
git \
-c split-diffs.min-line-width=80 \
-c split-diffs.wrap-lines=true \
-c split-diffs.highlight-line-changes=true \
-c split-diffs.theme-name=dark \
-c split-diffs.syntax-highlighting-theme=dark-plus \
show e250bec66b6c39d4c2f9e0e52a18245f16a7195a \
| git-split-diffs --color \
| pbcopy
*/
const expected = `
commit e250bec66b6c39d4c2f9e0e52a18245f16a7195a  
Author: Shrey Banga <banga.shrey@gmail.com>  
Date: Fri Dec 29 11:14:25 2023 -0500  
 
 Exclude lockfiles from diffs 
 
────────────────────────────────────────────────────────────────────────────────
 ■■ .gitattributes 
────────────────────────────────────────────────────────────────────────────────
@@ -0,0 +1,3 @@ 
 1  + # exclude lock files from git diff 
 2  + package-lock.json -diff 
 3  + yarn.lock -diff 
 
`;
const { stdout: actual } = spawnSync(
'node',
['./build/index.mjs', '--color'],
{ input, encoding: 'utf-8' }
);
console.log({ stdout, stderr });
assert.equal(stdout, expected);
if (actual !== expected) {
console.log('Expected:\n', expected);
console.log('Actual:\n', actual);
}
assert.equal(expected, actual);
}

main();

0 comments on commit 00cb4d2

Please sign in to comment.