mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Verify that snapshot can be executed via mksnapshot
This commit is contained in:
parent
e624f24b6d
commit
c2f02e16fe
@ -2,20 +2,26 @@ const fs = require('fs')
|
||||
const path = require('path')
|
||||
const electronLink = require('electron-link')
|
||||
const CONFIG = require('../config')
|
||||
const vm = require('vm')
|
||||
|
||||
module.exports = function () {
|
||||
const snapshotScriptPath = path.join(CONFIG.buildOutputPath, 'startup.js')
|
||||
console.log(`Generating snapshot script at "${snapshotScriptPath}"`)
|
||||
const coreModules = new Set([
|
||||
'path', 'electron', 'module', 'fs', 'child_process', 'crypto', 'url',
|
||||
'atom', 'vm', 'events', 'os', 'assert', 'buffer', 'tty', 'net', 'constants',
|
||||
'http', 'https', 'shell', 'querystring', 'zlib', 'stream', 'WNdb', 'lapack', 'remote'
|
||||
])
|
||||
const baseDirPath = path.join(CONFIG.intermediateAppPath, 'static')
|
||||
let processedFiles = 0
|
||||
const snapshotScriptContent = electronLink({
|
||||
baseDirPath,
|
||||
mainPath: path.resolve(baseDirPath, '..', 'src', 'initialize-application-window.js'),
|
||||
shouldExcludeModule: (modulePath) => {
|
||||
if (processedFiles > 0) {
|
||||
process.stdout.write('\r')
|
||||
}
|
||||
process.stdout.write(`Generating snapshot script at "${snapshotScriptPath}" (${++processedFiles})`)
|
||||
|
||||
const relativePath = path.relative(baseDirPath, modulePath)
|
||||
return (
|
||||
modulePath.endsWith('.node') || modulePath === 'buffer-offset-index' ||
|
||||
@ -69,4 +75,8 @@ module.exports = function () {
|
||||
}
|
||||
})
|
||||
fs.writeFileSync(snapshotScriptPath, snapshotScriptContent)
|
||||
process.stdout.write('\n')
|
||||
|
||||
console.log('Verifying if snapshot can be executed via `mksnapshot`')
|
||||
vm.runInNewContext(snapshotScriptContent, undefined, {filename: snapshotScriptPath, displayErrors: true})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user