@ryanatkn/gro 0.119.0 → 0.119.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // generated by src/lib/package.gen.ts
2
2
  export const package_json = {
3
3
  name: '@ryanatkn/gro',
4
- version: '0.119.0',
4
+ version: '0.119.1',
5
5
  description: 'task runner and toolkit extending SvelteKit',
6
6
  motto: 'generate, run, optimize',
7
7
  icon: '🌰',
@@ -258,7 +258,7 @@ export const package_json = {
258
258
  };
259
259
  export const src_json = {
260
260
  name: '@ryanatkn/gro',
261
- version: '0.119.0',
261
+ version: '0.119.1',
262
262
  modules: {
263
263
  '.': {
264
264
  path: 'index.ts',
package/dist/task.js CHANGED
@@ -3,15 +3,19 @@ export const TASK_FILE_SUFFIX_TS = '.task.ts';
3
3
  export const TASK_FILE_SUFFIX_JS = '.task.js';
4
4
  export const is_task_path = (path) => path.endsWith(TASK_FILE_SUFFIX_TS) || path.endsWith(TASK_FILE_SUFFIX_JS);
5
5
  export const to_task_name = (id, task_root_paths) => {
6
- let base_path = id;
7
- // If the id is in any of the task root paths, use the first match and strip it.
8
- for (const task_root_path of task_root_paths) {
9
- if (id.startsWith(task_root_path)) {
10
- base_path = strip_start(strip_start(id, task_root_path), '/');
11
- break;
6
+ // If the id is in any of the task root paths, use the longest available match and strip it.
7
+ // This is convoluted because we're not tracking which root path was resolved against the id.
8
+ // TODO improve the data flow of id from task root path so this is unnecessary
9
+ let longest_matching_path = '';
10
+ for (const path of task_root_paths) {
11
+ if (id.startsWith(path) && path.length > longest_matching_path.length) {
12
+ longest_matching_path = path;
12
13
  }
13
14
  }
14
- return strip_end(strip_end(base_path, TASK_FILE_SUFFIX_TS), TASK_FILE_SUFFIX_JS);
15
+ const task_name = longest_matching_path
16
+ ? strip_start(strip_start(id, longest_matching_path), '/')
17
+ : id;
18
+ return strip_end(strip_end(task_name, TASK_FILE_SUFFIX_TS), TASK_FILE_SUFFIX_JS);
15
19
  };
16
20
  /**
17
21
  * This is used by tasks to signal a known failure.
package/dist/task.test.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { test } from 'uvu';
2
2
  import * as assert from 'uvu/assert';
3
+ import { resolve } from 'node:path';
3
4
  import { is_task_path, to_task_name } from './task.js';
4
5
  test('is_task_path basic behavior', () => {
5
6
  assert.ok(is_task_path('foo.task.ts'));
@@ -14,5 +15,10 @@ test('to_task_name basic behavior', () => {
14
15
  assert.is(to_task_name('a/b/c/foo.task.ts', ['a/b/c', 'a']), 'foo');
15
16
  assert.is(to_task_name('a/b/c/foo.task.ts', ['a']), 'b/c/foo');
16
17
  assert.is(to_task_name('a/b/c/foo.task.ts', ['a/b', 'a']), 'c/foo');
18
+ assert.is(to_task_name(resolve('node_modules/@ryanatkn/gro/dist/foo'), [
19
+ resolve('./'),
20
+ resolve('node_modules/@ryanatkn/gro/dist/'),
21
+ ]), 'foo', 'resolves to node_modules before the cwd');
22
+ assert.is(to_task_name(resolve('a/b'), [resolve('b')]), resolve('a/b'), 'falls back to the id when unresolved');
17
23
  });
18
24
  test.run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryanatkn/gro",
3
- "version": "0.119.0",
3
+ "version": "0.119.1",
4
4
  "description": "task runner and toolkit extending SvelteKit",
5
5
  "motto": "generate, run, optimize",
6
6
  "icon": "🌰",