summaryrefslogtreecommitdiff
path: root/node_modules/electron-packager/src/prune.js
diff options
context:
space:
mode:
authorLinuxWizard42 <computerwizard@linuxmail.org>2022-10-12 23:08:57 +0300
committerLinuxWizard42 <computerwizard@linuxmail.org>2022-10-12 23:08:57 +0300
commit726b81b19251674e149ccfbb1abacbd837fc6db0 (patch)
treefbdbb227dc01357eb76e8222d76185bc124c5ca6 /node_modules/electron-packager/src/prune.js
parent34f0890e175698940d49238097579f44e4d78c89 (diff)
downloadFlashRunner-726b81b19251674e149ccfbb1abacbd837fc6db0.tar.gz
FlashRunner-726b81b19251674e149ccfbb1abacbd837fc6db0.tar.zst
Removed files that should not have been included in git
Diffstat (limited to 'node_modules/electron-packager/src/prune.js')
-rw-r--r--node_modules/electron-packager/src/prune.js68
1 files changed, 0 insertions, 68 deletions
diff --git a/node_modules/electron-packager/src/prune.js b/node_modules/electron-packager/src/prune.js
deleted file mode 100644
index e5739ef..0000000
--- a/node_modules/electron-packager/src/prune.js
+++ /dev/null
@@ -1,68 +0,0 @@
-'use strict'
-
-const common = require('./common')
-const galactus = require('galactus')
-const fs = require('fs-extra')
-const path = require('path')
-
-const ELECTRON_MODULES = [
- 'electron',
- 'electron-prebuilt',
- 'electron-prebuilt-compile'
-]
-
-class Pruner {
- constructor (dir) {
- this.baseDir = common.normalizePath(dir)
- this.galactus = new galactus.DestroyerOfModules({
- rootDirectory: dir,
- shouldKeepModuleTest: (module, isDevDep) => this.shouldKeepModule(module, isDevDep)
- })
- this.walkedTree = false
- }
-
- setModules (moduleMap) {
- const modulePaths = Array.from(moduleMap.keys()).map(modulePath => `/${common.normalizePath(modulePath)}`)
- this.modules = new Set(modulePaths)
- this.walkedTree = true
- }
-
- async pruneModule (name) {
- if (this.walkedTree) {
- return this.isProductionModule(name)
- } else {
- const moduleMap = await this.galactus.collectKeptModules({ relativePaths: true })
- this.setModules(moduleMap)
- return this.isProductionModule(name)
- }
- }
-
- shouldKeepModule (module, isDevDep) {
- if (isDevDep || module.depType === galactus.DepType.ROOT) {
- return false
- }
-
- if (ELECTRON_MODULES.includes(module.name)) {
- common.warning(`Found '${module.name}' but not as a devDependency, pruning anyway`)
- return false
- }
-
- return true
- }
-
- isProductionModule (name) {
- return this.modules.has(name)
- }
-}
-
-function isNodeModuleFolder (pathToCheck) {
- return path.basename(path.dirname(pathToCheck)) === 'node_modules' ||
- (path.basename(path.dirname(pathToCheck)).startsWith('@') && path.basename(path.resolve(pathToCheck, `..${path.sep}..`)) === 'node_modules')
-}
-
-module.exports = {
- isModule: async function isModule (pathToCheck) {
- return (await fs.pathExists(path.join(pathToCheck, 'package.json'))) && isNodeModuleFolder(pathToCheck)
- },
- Pruner: Pruner
-}