Skip to content

Commit

Permalink
chore(deps): install Jest dependencies via TypeScript and Node (#5928)
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann authored Aug 8, 2024
1 parent 3d26064 commit 70c4e8a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 36 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Please see our [Contributor Code of Conduct](https://github.com/ionic-team/stenc
1. There's no need to install a specific version of npm or Node right now, it shall be done automatically for you in
the next step
5. Run `npm ci`
6. Run `npm install.jest` to install dependencies for Stencil's testing submodule
6. Run `npm run install.jest` to install dependencies for Stencil's testing submodule


### Updates
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"clean.screenshots": "rm -rf test/end-to-end/screenshot/builds test/end-to-end/screenshot/images",
"clean:scripts": "rm -rf scripts/build",
"lint": "eslint 'bin/*' 'scripts/*.ts' 'scripts/**/*.ts' 'src/*.ts' 'src/**/*.ts' 'src/**/*.tsx' 'test/wdio/**/*.tsx'",
"install.jest": "bash ./src/testing/jest/install-dependencies.sh",
"install.jest": "npx tsx ./src/testing/jest/install-dependencies.mts",
"prettier": "npm run prettier.base -- --write",
"prettier.base": "prettier --cache \"./({bin,scripts,src,test}/**/*.{ts,tsx,js,jsx})|bin/stencil|.github/(**/)?*.(yml|yaml)|*.js\"",
"prettier.dry-run": "npm run prettier.base -- --list-different",
Expand Down
39 changes: 39 additions & 0 deletions src/testing/jest/install-dependencies.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { exec } from 'node:child_process';
import fss from 'node:fs';
import fs from 'node:fs/promises';
import path from 'node:path'
import url from 'node:url'

const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
let found = false;

const jestAdapters = (await fs.readdir(__dirname))
.filter((file) => file.startsWith('jest-'))
.filter((file) => fss.statSync(path.join(__dirname, file)).isDirectory());

/**
* Loop through directories start with 'jest-', e.g. `jest-27-and-under`, `jest-28`, etc.
*/
for (const dir of jestAdapters) {
found = true;

const jestDir = path.join(__dirname, dir);
console.log(`→ Installing dependencies in ${jestDir}...`);
await new Promise<void>((resolve, reject) => {
exec('npm ci', { cwd: jestDir }, (err) => {
if (err) {
reject(err);
}
resolve();
});
});
console.log('Done 🎉');
}

/**
* If no directories were found and processed, print an error and exit
*/
if (!found) {
console.error('Error: No jest directories were found');
process.exit(1);
}
34 changes: 0 additions & 34 deletions src/testing/jest/install-dependencies.sh

This file was deleted.

0 comments on commit 70c4e8a

Please sign in to comment.