Skip to content

Commit

Permalink
add assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 6, 2022
1 parent f5a9bb7 commit 8fd1657
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions scripts/build.js
Expand Up @@ -20,6 +20,7 @@

'use strict';

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const babel = require('@babel/core');
Expand Down Expand Up @@ -56,15 +57,20 @@ function getBuildPath(file, buildFolder) {
return path.resolve(pkgBuildPath, relativeToSrcPath).replace(/\.ts$/, '.js');
}

function buildNodePackage(p) {
const srcDir = path.resolve(p, SRC_DIR);
function buildNodePackage({packageDir, pkg}) {
const srcDir = path.resolve(packageDir, SRC_DIR);
const pattern = path.resolve(srcDir, '**/*');
const files = glob.sync(pattern, {nodir: true});

process.stdout.write(adjustToTerminalWidth(`${path.basename(p)}\n`));
process.stdout.write(adjustToTerminalWidth(`${pkg.name}\n`));

files.forEach(file => buildFile(file, true));

assert.ok(
fs.existsSync(path.resolve(packageDir, pkg.main)),
`Main file "${pkg.main}" in ${pkg.name} should exist`,
);

process.stdout.write(`${OK}\n`);
}

Expand Down Expand Up @@ -142,5 +148,5 @@ if (files.length) {
} else {
const packages = getPackages();
process.stdout.write(chalk.inverse(' Building packages \n'));
packages.map(({packageDir}) => packageDir).forEach(buildNodePackage);
packages.forEach(buildNodePackage);
}

0 comments on commit 8fd1657

Please sign in to comment.