Skip to content

Commit c49a993

Browse files
author
Michael Solomon
authored
stop using npm programming API (goldbergyoni#144)
1 parent b815190 commit c49a993

File tree

3 files changed

+7057
-15372
lines changed

3 files changed

+7057
-15372
lines changed

example-application/test/global-setup.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const isPortReachable = require('is-port-reachable');
22
const path = require('path');
33
const dockerCompose = require('docker-compose');
4-
const npm = require('npm');
5-
const util = require('util');
4+
const { execSync } = require('child_process');
65

76
module.exports = async () => {
87
console.time('global-setup');
@@ -25,12 +24,9 @@ module.exports = async () => {
2524
);
2625

2726
// ️️️✅ Best Practice: Use npm script for data seeding and migrations
28-
const npmLoadAsPromise = util.promisify(npm.load);
29-
await npmLoadAsPromise();
30-
const npmCommandAsPromise = util.promisify(npm.commands.run);
31-
await npmCommandAsPromise(['db:migrate']);
27+
execSync('npm run db:migrate');
3228
// ✅ Best Practice: Seed only metadata and not test record, read "Dealing with data" section for further information
33-
await npmCommandAsPromise(['db:seed']);
29+
execSync('npm run db:seed');
3430
}
3531

3632
// 👍🏼 We're ready

0 commit comments

Comments
 (0)