From 084e5039425984d5def7069198e76a3a15ad9236 Mon Sep 17 00:00:00 2001 From: Roman Schejbal Date: Fri, 20 Oct 2017 12:50:30 +0200 Subject: [PATCH 1/2] Rebuild native modules when node version changes. Fixes #756 --- src/cli/commands/install.js | 6 ++++++ src/integrity-checker.js | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/cli/commands/install.js b/src/cli/commands/install.js index 3488b80341..4a1568597a 100644 --- a/src/cli/commands/install.js +++ b/src/cli/commands/install.js @@ -424,6 +424,12 @@ export class Install { return false; } + if (match.nodeVersionDoesntMatch) { + // node version doesn't match, force script installations + this.scripts.setForce(true); + return false; + } + if (!patterns.length && !match.integrityFileMissing) { this.reporter.success(this.reporter.lang('nothingToInstall')); await this.createEmptyManifestFolders(); diff --git a/src/integrity-checker.js b/src/integrity-checker.js index 7e0e0adb50..841b849070 100644 --- a/src/integrity-checker.js +++ b/src/integrity-checker.js @@ -19,6 +19,7 @@ export const integrityErrors = { LINKED_MODULES_DONT_MATCH: 'integrityCheckLinkedModulesDontMatch', PATTERNS_DONT_MATCH: 'integrityPatternsDontMatch', MODULES_FOLDERS_MISSING: 'integrityModulesFoldersMissing', + NODE_VERSION_DOESNT_MATCH: 'integrityNodeDoesntMatch', }; type IntegrityError = $Keys; @@ -37,6 +38,7 @@ type IntegrityHashLocation = { }; type IntegrityFile = { + node_version: string, flags: Array, modulesFolders: Array, linkedModules: Array, @@ -54,6 +56,7 @@ type IntegrityFlags = { }; const INTEGRITY_FILE_DEFAULTS = () => ({ + node_version: process.version, modulesFolders: [], flags: [], linkedModules: [], @@ -295,6 +298,10 @@ export default class InstallationIntegrityChecker { return 'LINKED_MODULES_DONT_MATCH'; } + if (actual.node_version !== expected.node_version) { + return 'NODE_VERSION_DOESNT_MATCH'; + } + let relevantExpectedFlags = expected.flags.slice(); // If we run "yarn" after "yarn --check-files", we shouldn't fail the less strict validation @@ -386,6 +393,7 @@ export default class InstallationIntegrityChecker { integrityMatches: integrityMatches === 'OK', integrityError: integrityMatches === 'OK' ? undefined : integrityMatches, missingPatterns, + nodeVersionDoesntMatch: integrityMatches === 'NODE_VERSION_DOESNT_MATCH', }; } From 1fe3070405955df7d89fe7192f78bab2f0fad251 Mon Sep 17 00:00:00 2001 From: Roman Schejbal Date: Wed, 25 Oct 2017 10:30:11 +0200 Subject: [PATCH 2/2] Rebuild native modules when node version changes. Review feedback --- src/cli/commands/install.js | 4 ++-- src/integrity-checker.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cli/commands/install.js b/src/cli/commands/install.js index 4a1568597a..cad1269ca0 100644 --- a/src/cli/commands/install.js +++ b/src/cli/commands/install.js @@ -424,8 +424,8 @@ export class Install { return false; } - if (match.nodeVersionDoesntMatch) { - // node version doesn't match, force script installations + if (match.hardRefreshRequired) { + // e.g. node version doesn't match, force script installations this.scripts.setForce(true); return false; } diff --git a/src/integrity-checker.js b/src/integrity-checker.js index 841b849070..3dcd33c14f 100644 --- a/src/integrity-checker.js +++ b/src/integrity-checker.js @@ -38,7 +38,7 @@ type IntegrityHashLocation = { }; type IntegrityFile = { - node_version: string, + nodeVersion: string, flags: Array, modulesFolders: Array, linkedModules: Array, @@ -56,7 +56,7 @@ type IntegrityFlags = { }; const INTEGRITY_FILE_DEFAULTS = () => ({ - node_version: process.version, + nodeVersion: process.version, modulesFolders: [], flags: [], linkedModules: [], @@ -298,7 +298,7 @@ export default class InstallationIntegrityChecker { return 'LINKED_MODULES_DONT_MATCH'; } - if (actual.node_version !== expected.node_version) { + if (actual.nodeVersion !== expected.nodeVersion) { return 'NODE_VERSION_DOESNT_MATCH'; } @@ -393,7 +393,7 @@ export default class InstallationIntegrityChecker { integrityMatches: integrityMatches === 'OK', integrityError: integrityMatches === 'OK' ? undefined : integrityMatches, missingPatterns, - nodeVersionDoesntMatch: integrityMatches === 'NODE_VERSION_DOESNT_MATCH', + hardRefreshRequired: integrityMatches === 'NODE_VERSION_DOESNT_MATCH', }; }