Skip to content

Commit

Permalink
add initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Mar 19, 2023
1 parent d27a005 commit 43ed5c1
Show file tree
Hide file tree
Showing 10 changed files with 2,149 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false

[*.{diff,md}]
trim_trailing_whitespace = false
19 changes: 19 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
"env": {
"es2021": true,
"node": true
},
"extends": "eslint:recommended",
"overrides": [{
files: 'test/**/*.js',
env: {
mocha: true,
}
}],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
}
}
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm i -g npm@latest
- run: npm ci
- run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules/
30 changes: 30 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import walkSync from 'walk-sync';
import { readFileSync } from 'fs';
import { join } from 'path';

import { generateDiff } from 'mocha-diff';

const fixtureDir = process.argv[2];
const comparisonDir = process.argv[3];

if (!fixtureDir) {
console.error('You need to provide the path to a fixture and to the comparison dir');
process.exit(1);
}

if (!comparisonDir) {
console.error('You need to provide the path to the comparison dir');
process.exit(1);
}

const fixtureFiles = walkSync(fixtureDir, { directories: false });

fixtureFiles.forEach((file) => {
const compareFile = readFileSync(join(comparisonDir, file), 'utf8');
const fixtureFile = readFileSync(join(fixtureDir, file), 'utf8');

if (compareFile != fixtureFile) {
console.log(`${file} is different in the fixture 🚨`);
console.log(generateDiff(compareFile, fixtureFile));
}
})

0 comments on commit 43ed5c1

Please sign in to comment.