Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: test and add commands would silently fail #25

Merged
merged 5 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/curly-flies-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ts-blocks": patch
---

Fixed an issue with silent failures due to `import.meta.dirname` being undefined in `test` and `add` commands
3 changes: 2 additions & 1 deletion build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ export default defineBuildConfig({
'src/blocks',
'src/commands/add',
'src/commands/init',
'src/commands/test',
'src/commands/index',
'src/config/index',
'src/utils/index',
],
failOnWarn: false,
declaration: true,
clean: true,
});
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"type": "git",
"url": "git+https://github.com/ieedan/ts-blocks"
},
"keywords": [
"changelog",
"date"
],
"keywords": ["changelog", "date"],
"author": "Aidan Bleser",
"license": "MIT",
"bugs": {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { resolveCommand } from 'package-manager-detector/commands';
import { detect } from 'package-manager-detector/detect';
import { Project, type SourceFile } from 'ts-morph';
import { type InferInput, boolean, object, parse } from 'valibot';
import { INFO, WARN } from '.';
import { blocks } from '../blocks';
import { getConfig } from '../config';
import { INFO, WARN } from '../utils/index';

const schema = object({
yes: boolean(),
Expand Down Expand Up @@ -60,7 +60,7 @@ const _add = async (blockNames: string[], options: Options) => {

verbose(`Found block ${JSON.stringify(block)}`);

const registryDir = path.join(import.meta.dirname, '../../blocks');
const registryDir = path.join(import.meta.url, '../../../blocks').replace(/^file:\\/, '');

const registryFilePath = path.join(registryDir, `${block.category}/${blockName}.ts`);

Expand Down
7 changes: 1 addition & 6 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import color from 'chalk';
import { add } from './add';
import { init } from './init';
import { test } from './test';

const WARN = color.bgRgb(245, 149, 66).white('WARN');

const INFO = color.bgBlueBright.white('INFO');

export { add, init, test, WARN, INFO };
export { add, init, test };
2 changes: 1 addition & 1 deletion src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const _test = async (blockNames: string[], options: Options) => {
}
};

const registryDir = path.join(import.meta.dirname, '../../blocks');
const registryDir = path.join(import.meta.url, '../../../blocks').replace(/^file:\\/, '');

type TestInfo = {
command: string;
Expand Down
7 changes: 7 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import color from 'chalk';

const WARN = color.bgRgb(245, 149, 66).white('WARN');

const INFO = color.bgBlueBright.white('INFO');

export { WARN, INFO };