在电子产品中,当使用电子打包程序打包应用程序 时,如何编写文件。
以下内容将创建和更新开发中的文件。但是一旦我使用electronic-packager打包应用程序,该文件将不再创建。我需要更改什么?
params
这是我的打包方式:
// imports
const path = require('path');
const fs = require('fs');
// create stream for appending to the log file
stream = fs.createWriteStream(
path.join(__dirname, 'logfile.log'),
{
flags:'a'
}
);
// append content to the log file
stream.write('test');
答案 0 :(得分:0)
我还没有尝试过,但是也许您可以使用afterCopy钩子来调用所需的函数?
复制后
函数数组
应用目录被调用后要调用的函数数组 复制到一个临时目录。每个函数有五个 参数:
buildPath (String): The path to the temporary folder where your app has been copied to electronVersion (String): The version of electron you are packaging for platform (String): The target platform you are packaging for arch (String): The target architecture you are packaging for callback (Function): Must be called once you have completed your actions
const packager = require('electron-packager')
const { serialHooks } = require('electron-packager/hooks')
packager({
// ...
afterCopy: [serialHooks([
(buildPath, electronVersion, platform, arch) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log('first function')
resolve()
}, 1000)
})
},
(buildPath, electronVersion, platform, arch) => {
console.log('second function')
}
])],
// ...
})