Skip to content

Commit 266b9f6

Browse files
authored
Added a check specifically for M1 CPUs to fix postgres error when running graph test (#764)
* added additional check for m1 macs * changed the if conditions a bit * added semver as a major version checker
1 parent 2b68614 commit 266b9f6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/commands/test.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { Binary } = require('binary-install-raw')
22
const os = require('os')
33
const chalk = require('chalk')
44
const fetch = require('node-fetch')
5+
const semver = require('semver')
56

67
const HELP = `
78
${chalk.bold('graph test')} ${chalk.dim('[options]')} ${chalk.bold('<datasource>')}
@@ -53,16 +54,20 @@ function getPlatform() {
5354
const type = os.type();
5455
const arch = os.arch();
5556
const release = os.release();
56-
const majorVersion = release.substr(0, release.indexOf('.'));
57+
const cpuCore = os.cpus()[0];
58+
const majorVersion = semver.major(release);
59+
const isM1 = cpuCore.model.includes("Apple M1");
5760

58-
if (arch === 'x64') {
61+
if (arch === 'x64' || (arch === 'arm64' && isM1)) {
5962
if (type === 'Darwin') {
6063
if (majorVersion === '19') {
6164
return 'binary-macos-10.15';
6265
} else if (majorVersion === '18') {
6366
return 'binary-macos-10.14';
67+
} else if (isM1) {
68+
return 'binary-macos-11-m1';
6469
}
65-
return 'binary-macos-11'
70+
return 'binary-macos-11';
6671
} else if (type === 'Linux') {
6772
if (majorVersion === '18') {
6873
return 'binary-linux-18';

0 commit comments

Comments
 (0)