Skip to content

Commit

Permalink
Merge pull request #7300 from telamonian/fix-ensure-buildutils
Browse files Browse the repository at this point in the history
Fix ensure-buildutils.js: rebuilds correctly on changes, runs pre integrity
  • Loading branch information
telamonian committed Oct 8, 2019
2 parents c39e611 + a2ba20e commit 1293dd2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion buildutils/src/ensure-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export async function ensureUiComponents(
const iconModelDeclarations = _iconModelDeclarations.join(',\n');

// generate the actual contents of the iconImports file
const iconImportsPath = path.join(iconSrcDir, 'iconImports.ts');
const iconImportsPath = path.join(iconSrcDir, 'iconimports.ts');
const iconImportsContents = utils.fromTemplate(
HEADER_TEMPLATE + ICON_IMPORTS_TEMPLATE,
{ funcName, iconImportStatements, iconModelDeclarations }
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"eslint:check": "eslint .",
"get:dependency": "node buildutils/lib/get-dependency.js",
"postinstall": "node scripts/ensure-buildutils.js",
"integrity": "node buildutils/lib/ensure-repo.js",
"integrity": "node scripts/ensure-buildutils.js && node buildutils/lib/ensure-repo.js",
"lighthouse": "lighthouse http://localhost:8888/ --chrome-flags='--headless' --emulated-form-factor=none --throttling-method=provided --only-categories performance",
"lighthouse:compare": "node testutils/lib/compare-lighthouse.js",
"lighthouse:throttling:start": "comcast --latency=40 --target-bw=30000 --packet-loss=0.2%",
Expand Down
28 changes: 22 additions & 6 deletions scripts/ensure-buildutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,40 @@
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
// uncomment to time script
// var start = new Date();

var fs = require('fs-extra');
var glob = require('glob');
var path = require('path');
var childProcess = require('child_process');

var basePath = path.join(path.resolve('.'), 'buildutils');

// Make sure that buildutils is built and current
var current = true;
if (fs.existsSync(path.join('buildutils', 'lib'))) {
var srcFiles = glob.sync(path.join('buildutils', 'src', '*'));
var libFiles = glob.sync(path.join('buildutils', 'lib', '*'));
if (fs.existsSync(path.join(basePath, 'lib'))) {
var srcFiles = glob.sync(path.join(basePath, 'src', '*'));
var libFiles = glob.sync(path.join(basePath, 'lib', '*'));
srcFiles.forEach(function(srcPath) {
// Bail early if already not current
// bail early if already not current
if (!current) {
return;
}

if (srcPath.endsWith('.d.ts')) {
// bail if this is a src declarations file
return;
}

var name = path.basename(srcPath);
var ext = path.extname(name);
if (ext !== 'js') {
if (ext !== '.ts') {
current = false;
return;
}
var libPath = path.join('buildutils', 'lib', name.replace('.ts', '.js'));

var libPath = path.join(basePath, 'lib', name.replace('.ts', '.js'));
if (libFiles.indexOf(libPath) === -1) {
current = false;
return;
Expand All @@ -46,3 +58,7 @@ if (!current) {
cwd: path.resolve('./buildutils')
});
}

// uncomment to time script
// var end = new Date() - start;
// console.info('Execution time: %dms', end);

0 comments on commit 1293dd2

Please sign in to comment.