Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn committed Apr 9, 2021
1 parent 8cb654d commit c1f61af
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/test.task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import {Timings} from './utils/time.js';
import {spawnProcess} from './utils/process.js';
import {toBuildOutPath, toRootPath} from './paths.js';
import {PRIMARY_NODE_BUILD_CONFIG_NAME} from './config/defaultBuildConfig.js';
import {pathExists} from './fs/node.js';
import {loadGroConfig} from './config/config.js';
import {buildSourceDirectory} from './build/buildSourceDirectory.js';

// Runs the project's tests: `gro test [...args]`
// Args are passed through directly to `uvu`'s CLI:
Expand All @@ -17,12 +20,31 @@ export const task: Task = {
run: async ({dev, log, args}): Promise<void> => {
const timings = new Timings();

const dir = toRootPath(toBuildOutPath(dev, PRIMARY_NODE_BUILD_CONFIG_NAME));
const testsBuildDir = toBuildOutPath(dev, PRIMARY_NODE_BUILD_CONFIG_NAME);

// TODO cleaner way to detect & rebuild?
if (!(await pathExists(testsBuildDir))) {
const timingToLoadConfig = timings.start('load config');
const config = await loadGroConfig(dev);
timingToLoadConfig();

const timingToPrebuild = timings.start('prebuild');
await buildSourceDirectory(config, dev, log);
timingToPrebuild();

// Projects may not define any artifacts for the Node build,
// and we don't force anything out in that case,
// so just exit early if that happens.
if (!(await pathExists(testsBuildDir))) {
log.info('no tests found');
return;
}
}

const timeToRunUvu = timings.start('run test with uvu');
const testRunResult = await spawnProcess('npx', [
'uvu',
dir,
toRootPath(testsBuildDir),
...(args._.length ? args._ : DEFAULT_TEST_FILE_PATTERNS),
...process.argv.slice(3),
]);
Expand Down
1 change: 1 addition & 0 deletions src/version.task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const task: Task<TaskArgs> = {
// think of a better way - maybe config+defaults?
// I don't want to touch Gro's prod build pipeline right now using package.json `"preversion"`
if (!isThisProjectGro) {
await invokeTask('check');
await invokeTask('build');
}
await spawnProcess('npm', ['version', ...process.argv.slice(3)]);
Expand Down

0 comments on commit c1f61af

Please sign in to comment.