mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-09-22 17:49:02 +00:00
Make app resource folder contain a short id string, fix #21
This commit is contained in:
parent
762de5f1c8
commit
7bfedc823b
@ -1,5 +1,6 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import crypto from 'crypto';
|
||||||
|
|
||||||
import packager from 'electron-packager';
|
import packager from 'electron-packager';
|
||||||
import tmp from 'tmp';
|
import tmp from 'tmp';
|
||||||
@ -86,11 +87,18 @@ function copyPlaceholderApp(srcAppDir, tempDir, name, targetURL, badge, width, h
|
|||||||
// change name of packageJson so that temporary files will not be shared across different app instances
|
// change name of packageJson so that temporary files will not be shared across different app instances
|
||||||
const packageJsonPath = path.join(tempDir, '/package.json');
|
const packageJsonPath = path.join(tempDir, '/package.json');
|
||||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath));
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath));
|
||||||
packageJson.name = _.kebabCase(appArgs.name + '-nativefier');
|
packageJson.name = normalizeAppName(appArgs.name);
|
||||||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson));
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson));
|
||||||
|
|
||||||
callback(null, tempDir);
|
callback(null, tempDir);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
function normalizeAppName(appName) {
|
||||||
|
// use a simple 3 byte random string to prevent collision
|
||||||
|
const postFixHash = crypto.randomBytes(3).toString('hex');
|
||||||
|
const normalized = _.kebabCase(appName.toLowerCase());
|
||||||
|
return `${normalized}-nativefier-${postFixHash}`;
|
||||||
|
}
|
||||||
|
|
||||||
export default buildApp;
|
export default buildApp;
|
||||||
|
Loading…
Reference in New Issue
Block a user