build: enable JS semicolons (#22783)

This commit is contained in:
Samuel Attard 2020-03-20 13:28:31 -07:00 committed by GitHub
parent 24e21467b9
commit 5d657dece4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
354 changed files with 21512 additions and 21510 deletions

View file

@ -1,42 +1,42 @@
import * as path from 'path'
import * as path from 'path';
const Module = require('module')
const Module = require('module');
// Clear Node's global search paths.
Module.globalPaths.length = 0
Module.globalPaths.length = 0;
// Prevent Node from adding paths outside this app to search paths.
const resourcesPathWithTrailingSlash = process.resourcesPath + path.sep
const originalNodeModulePaths = Module._nodeModulePaths
const resourcesPathWithTrailingSlash = process.resourcesPath + path.sep;
const originalNodeModulePaths = Module._nodeModulePaths;
Module._nodeModulePaths = function (from: string) {
const paths: string[] = originalNodeModulePaths(from)
const fromPath = path.resolve(from) + path.sep
const paths: string[] = originalNodeModulePaths(from);
const fromPath = path.resolve(from) + path.sep;
// If "from" is outside the app then we do nothing.
if (fromPath.startsWith(resourcesPathWithTrailingSlash)) {
return paths.filter(function (candidate) {
return candidate.startsWith(resourcesPathWithTrailingSlash)
})
return candidate.startsWith(resourcesPathWithTrailingSlash);
});
} else {
return paths
return paths;
}
}
};
// Make a fake Electron module that we will insert into the module cache
const electronModule = new Module('electron', null)
electronModule.id = 'electron'
electronModule.loaded = true
electronModule.filename = 'electron'
const electronModule = new Module('electron', null);
electronModule.id = 'electron';
electronModule.loaded = true;
electronModule.filename = 'electron';
Object.defineProperty(electronModule, 'exports', {
get: () => require('electron')
})
});
Module._cache.electron = electronModule
Module._cache.electron = electronModule;
const originalResolveFilename = Module._resolveFilename
const originalResolveFilename = Module._resolveFilename;
Module._resolveFilename = function (request: string, parent: NodeModule, isMain: boolean) {
if (request === 'electron') {
return 'electron'
return 'electron';
} else {
return originalResolveFilename(request, parent, isMain)
return originalResolveFilename(request, parent, isMain);
}
}
};