@tapjs/run
Version:
Command-line interface for the node-tap runner
30 lines • 1.12 kB
JavaScript
// import this first so Test exists when we need it.
import '@tapjs/core';
import { defaultPlugins } from '@tapjs/test';
import { getInstalledVersion } from './get-installed-version.js';
import { selectVersion } from './select-version.js';
// @scope/pkg
// @scope/pkg@semver
// pkg
// pkg@semver
const pkgRe = /^(@[^\.\/_][^\/]*\/[^@\._\/][^@]*|[^\._@\/][^@\/]*)(?:@(.*))?$/;
/**
* If it's a package, figure out what version we have, what version
* we want, and what the parsed name of the plugin is.
*/
export const analyzePluginArg = async (plugin, config) => {
const pkgMatch = plugin.match(pkgRe);
if (!pkgMatch || defaultPlugins.includes(plugin)) {
// just a folder, not a versioned thing from the registry.
return {
name: plugin,
versionWant: '',
versionInstalled: '',
};
}
const name = pkgMatch[1];
const versionInstalled = getInstalledVersion(name, config);
const versionWant = await selectVersion(name, pkgMatch[2], config);
return { name, versionInstalled, versionWant };
};
//# sourceMappingURL=analyze-plugin-arg.js.map