diff --git a/check.js b/check.js index 71ee24c..09e4766 100644 --- a/check.js +++ b/check.js @@ -27,23 +27,10 @@ if (disabledForMachine || disabledForProject) { `); } try { - fs.renameSync('vaadin-usage-statistics.js', 'vaadin-usage-statistics.js.bak'); + fs.copyFileSync('vaadin-usage-statistics-optout.js', 'vaadin-usage-statistics.js'); } catch (err) { - if (err.code === 'ENOENT') { - console.log('File not found!'); - } else { - throw err; - } - } - - try { - fs.renameSync('vaadin-usage-statistics-optout.js', 'vaadin-usage-statistics.js'); - } catch (err) { - if (err.code === 'ENOENT') { - console.log('File not found!'); - } else { - throw err; - } + console.log('Error while copying file!'); + throw err; } } else { console.log(` @@ -55,28 +42,11 @@ if (disabledForMachine || disabledForProject) { For more details, see https://github.com/vaadin/vaadin-usage-statistics `); - /* restore backup files if previously disabled */ - if (fs.existsSync('vaadin-usage-statistics.js.bak')) { - try { - fs.renameSync('vaadin-usage-statistics.js', 'vaadin-usage-statistics-optout.js'); - } catch (err) { - if (err.code === 'ENOENT') { - console.log('File not found!'); - } else { - throw err; - } - } - - try { - fs.renameSync('vaadin-usage-statistics.js.bak', 'vaadin-usage-statistics.js'); - } catch (err) { - if (err.code === 'ENOENT') { - console.log('File not found!'); - - } else { - throw err; - } - } + try { + fs.copyFileSync('vaadin-usage-statistics-collect.js', 'vaadin-usage-statistics.js'); + } catch (err) { + console.log('Error while copying file!'); + throw err; } } diff --git a/gulpfile.js b/gulpfile.js index da14796..c2cda85 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,7 +7,7 @@ const { promisify } = require('util'); const exec = promisify(require('child_process').exec); async function rebuild() { - await fs.remove(path.join(__dirname, 'vaadin-usage-statistics.html')); + await fs.remove(path.join(__dirname, 'vaadin-usage-statistics-collect.html')); const template = await fs.readFile( path.join(__dirname, 'src/vaadin-usage-statistics.tpl.html'), 'utf-8'); @@ -17,7 +17,7 @@ async function rebuild() { path.join(__dirname, 'vaadin-usage-statistics.es5.js'), 'utf-8'); await fs.outputFile( - path.join(__dirname, 'vaadin-usage-statistics.html'), + path.join(__dirname, 'vaadin-usage-statistics-collect.html'), '\n' + template.replace('${vaadin-usage-statistics.js}', bundle)); @@ -37,7 +37,7 @@ gulp.task('auto-amend-commit', async () => { const depsStaged = rc.stdout.split('\n').some(file => deps.includes(file)); if (depsStaged) { await rebuild(); - await exec('git add vaadin-usage-statistics.html'); + await exec('git add vaadin-usage-statistics-collect.html'); } }); diff --git a/package.json b/package.json index 37ea08a..7b5de27 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "IE 11" ], "files": [ - "vaadin-usage-statistics.js", + "vaadin-usage-statistics-collect.js", "vaadin-usage-statistics-optout.js", "check.js" ], diff --git a/vaadin-usage-statistics-collect.html b/vaadin-usage-statistics-collect.html new file mode 100644 index 0000000..ed06313 --- /dev/null +++ b/vaadin-usage-statistics-collect.html @@ -0,0 +1,507 @@ + + + + + diff --git a/vaadin-usage-statistics.html b/vaadin-usage-statistics.html index ed06313..c4af622 100644 --- a/vaadin-usage-statistics.html +++ b/vaadin-usage-statistics.html @@ -1,507 +1 @@ - - - - - +