mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-29 00:10:54 +05:30
#242: do not rebuild dlls, when they are up to date
This commit is contained in:
parent
6fc061b5b2
commit
146cbcd922
@ -1,6 +1,8 @@
|
|||||||
/* eslint-env node */
|
/* eslint-env node */
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
|
|
||||||
@ -8,14 +10,59 @@ const webpackConfig = require('../webpack.dll.config.js');
|
|||||||
|
|
||||||
const compiler = webpack(webpackConfig);
|
const compiler = webpack(webpackConfig);
|
||||||
|
|
||||||
compiler.run(function(err, stats) {
|
Promise.all([
|
||||||
if (err) {
|
stat(__dirname + '/../npm-shrinkwrap.json'),
|
||||||
console.error(chalk.red(err));
|
stat(__dirname + '/../dll/vendor.json')
|
||||||
process.exit(1);
|
])
|
||||||
|
.then(function(stats) {
|
||||||
|
const shrinkwrap = new Date(stats[0].mtime);
|
||||||
|
const dll = new Date(stats[1].mtime);
|
||||||
|
|
||||||
|
if (dll < shrinkwrap) {
|
||||||
|
return Promise.reject({
|
||||||
|
code: 'OUTDATED'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(
|
logResult(chalk.green('Current dlls are up to date!'));
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
if (err.code !== 'ENOENT' && err.code !== 'OUTDATED') {
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Rebuilding dlls...');
|
||||||
|
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
compiler.run(function(err, stats) {
|
||||||
|
if (err) {
|
||||||
|
return reject(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
logResult(
|
||||||
chalk.green('Dll was successfully build in %s ms'),
|
chalk.green('Dll was successfully build in %s ms'),
|
||||||
stats.endTime - stats.startTime
|
stats.endTime - stats.startTime
|
||||||
);
|
);
|
||||||
|
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
logResult(chalk.red('Unexpected error checking dll state'), err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
function logResult() {
|
||||||
|
console.log('\n');
|
||||||
|
console.log.apply(console, arguments);
|
||||||
|
console.log('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
function stat(path) {
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
fs.stat(path, function(err, stats) {
|
||||||
|
err ? reject(err) : resolve(stats);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user