Skip to content

Commit

Permalink
Add type checking script and build step from clients
Browse files Browse the repository at this point in the history
  • Loading branch information
addisonbeck committed Jan 11, 2024
1 parent 9965c2d commit 9f8be98
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@ jobs:
- name: Install Node dependencies
run: npm ci

# We use isolatedModules: true which disables typechecking in tests
# Tests in apps/ are typechecked when their app is built, so we just do it here for libs/
# See https://bitwarden.atlassian.net/browse/EC-497
- name: Run typechecking
run: npm run test:types --coverage

- name: Run tests
run: npm run test
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"prepare": "husky install",
"test": "jest",
"test:watch": "jest --watch",
"test:watch:all": "jest --watchAll"
"test:watch:all": "jest --watchAll",
"test:types": "node ./scripts/test-types.js"
},
"devDependencies": {
"@angular-devkit/build-angular": "15.2.9",
Expand Down
29 changes: 29 additions & 0 deletions scripts/test-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const concurrently = require("concurrently");
const path = require("path");
const fs = require("fs");

function getFiles(dir) {
results = [];
fs.readdirSync(dir).forEach((file) => {
file = path.join(dir, file);
const stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
results = results.concat(getFiles(file));
} else {
results.push(file);
}
});
return results;
}

const files = getFiles(path.join(__dirname, "../src", "../jslib")).filter((file) => {
const name = path.basename(file);
return name === "tsconfig.json";
});

concurrently(
files.map((file) => ({
name: path.basename(path.dirname(file)),
command: `npx tsc --noEmit --project ${file}`,
}))
);

0 comments on commit 9f8be98

Please sign in to comment.