Skip to content

Commit 30ef802

Browse files
committed
Fix postinstall script, $(pwd) resolving incorrectly on AppVeyor
1 parent c10b917 commit 30ef802

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

scripts/postinstall.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ function downloadMailsync() {
101101
// For speed, we cache app/node_modules. However, we need to
102102
// be sure to do a full rebuild of native node modules when the
103103
// Electron version changes. To do this we check a marker file.
104-
const appModulesPath = path.resolve(__dirname, '..', 'app', 'node_modules');
104+
const appPath = path.resolve(__dirname, '..', 'app');
105+
const appModulesPath = path.resolve(appPath, 'node_modules');
105106
const cacheVersionPath = path.join(appModulesPath, '.postinstall-target-version');
106107
const cacheElectronTarget =
107108
fs.existsSync(cacheVersionPath) && fs.readFileSync(cacheVersionPath).toString();
@@ -139,13 +140,19 @@ async function run() {
139140
await npm(`ls`, { cwd: './app', env: 'electron' });
140141

141142
// rebuild sqlite3 using our custom amalgamation, which has USLEEP enabled
142-
if (await sqliteMissingUsleep()) {
143+
if (process.platform === 'win32' || (await sqliteMissingUsleep())) {
144+
// remove the existing build so NPM can't see that it's already present
143145
rimraf.sync(path.join(appModulesPath, 'better-sqlite3'));
146+
// install the module pointing to our local sqlite source with custom #DEFINEs set
147+
const amalgamationPath = path.join(appPath, 'build', 'sqlite-amalgamation');
144148
await npm(
145149
`install better-sqlite3@${appDependencies['better-sqlite3']} ` +
146-
`--no-save --no-audit --build-from-source --sqlite3="$(pwd)/build/sqlite-amalgamation"`,
150+
`--no-save --no-audit --build-from-source --sqlite3="${amalgamationPath}"`,
147151
{ cwd: './app', env: 'electron' }
148152
);
153+
// remove the build symlinks so that we can build an installer for the app without
154+
// symlinks out to the sqlite-amalgamation directory.
155+
rimraf.sync(path.join(appModulesPath, 'better-sqlite3', 'build', 'Release', 'obj'));
149156
}
150157

151158
// if SQlite was STILL not built with HAVE_USLEEP, do not ship this build! We need usleep

0 commit comments

Comments
 (0)