feature: ELECTRON-1204: allow set expiry to take period dynamically

This commit is contained in:
Vishwas Shashidhar 2019-06-25 13:35:40 +05:30
parent 2e80c599fc
commit 1b79deb24a
2 changed files with 5 additions and 4 deletions

View File

@ -48,20 +48,22 @@ gulp.task('copy', function () {
*/
gulp.task('setExpiry', function (done) {
// Set expiry of 15 days for test builds we create from CI
const expiryDays = 15;
const expiryDays = process.argv[4] || 15;
console.log(`Setting expiry to ${expiryDays} days`);
const milliseconds = 24*60*60*1000;
const expiryTime = new Date().getTime() + (expiryDays * milliseconds);
console.log(`Setting expiry time to ${expiryTime}`);
const ttlHandlerFile = path.join(__dirname, 'src/app/ttl-handler.ts');
fs.readFile(ttlHandlerFile, 'utf8', function (err,data) {
if (err) {
console.log(err);
console.error(err);
return done(err);
}
// Do a simple search and replace in the `ttl-handler.ts` file
const replacementString = `const ttlExpiryTime = ${expiryTime}`;
var result = data.replace(/const ttlExpiryTime = -1/g, replacementString);
const result = data.replace(/const ttlExpiryTime = -1/g, replacementString);
fs.writeFile(ttlHandlerFile, result, 'utf8', function (err) {
if (err) {

View File

@ -19,7 +19,6 @@
"packed-mac": "npm run unpacked-mac && packagesbuild -v installer/mac/symphony-mac-packager.pkgproj",
"prebuild": "npm run compile && npm run rebuild && npm run browserify-preload",
"rebuild": "electron-rebuild -f",
"setexpiry": "gulp setExpiry",
"start": "npm run compile && npm run browserify-preload && cross-env ELECTRON_DEV=true electron .",
"test": "npm run lint && cross-env ELECTRON_QA=true jest --config jest.config.json --runInBand",
"unpacked-mac": "npm run prebuild && npm run test && build --mac --dir",