Skip to content

Commit

Permalink
Merge pull request #25 from ieedan/fix-silent-fail
Browse files Browse the repository at this point in the history
fix: `test` and `add` commands would silently fail
  • Loading branch information
ieedan authored Sep 16, 2024
2 parents bd2b953 + e30ea61 commit 10dd153
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
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 };

0 comments on commit 10dd153

Please sign in to comment.