mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-02-08 22:18:25 +00:00
make app data folder consistent per URL
This commit is contained in:
parent
88bb589de8
commit
76fe17e39f
@ -24,15 +24,15 @@ function buildApp(src, dest, options, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFileSync(path.join(dest, '/nativefier.json'), JSON.stringify(appArgs));
|
fs.writeFileSync(path.join(dest, '/nativefier.json'), JSON.stringify(appArgs));
|
||||||
changeAppPackageJsonName(dest, appArgs.name);
|
changeAppPackageJsonName(dest, appArgs.name, appArgs.targetUrl);
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeAppPackageJsonName(appPath, name) {
|
function changeAppPackageJsonName(appPath, name, url) {
|
||||||
const packageJsonPath = path.join(appPath, '/package.json');
|
const packageJsonPath = path.join(appPath, '/package.json');
|
||||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath));
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath));
|
||||||
packageJson.name = normalizeAppName(name);
|
packageJson.name = normalizeAppName(name, url);
|
||||||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson));
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,9 +55,11 @@ function selectAppArgs(options) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeAppName(appName) {
|
function normalizeAppName(appName, url) {
|
||||||
// use a simple 3 byte random string to prevent collision
|
// use a simple 3 byte random string to prevent collision
|
||||||
const postFixHash = crypto.randomBytes(3).toString('hex');
|
let hash = crypto.createHash('md5');
|
||||||
|
hash.update(url);
|
||||||
|
const postFixHash = hash.digest('hex').substring(0, 6);
|
||||||
const normalized = _.kebabCase(appName.toLowerCase());
|
const normalized = _.kebabCase(appName.toLowerCase());
|
||||||
return `${normalized}-nativefier-${postFixHash}`;
|
return `${normalized}-nativefier-${postFixHash}`;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user