@fnndsc/cumin 3.29.1 → 3.29.3
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/path/chrisPath.d.ts +11 -8
- package/dist/path/chrisPath.js +24 -28
- package/dist/path/chrisPath.js.map +1 -1
- package/package.json +2 -2
package/dist/path/chrisPath.d.ts
CHANGED
|
@@ -23,23 +23,26 @@
|
|
|
23
23
|
*/
|
|
24
24
|
export declare function path_isInFeed(dirPath: string): boolean;
|
|
25
25
|
/**
|
|
26
|
-
* Extracts the plugin instance ID
|
|
27
|
-
* ancestor directory matching the pattern: <plugin-name>_<instanceID>
|
|
26
|
+
* Extracts the plugin instance ID of the feed node a path is in.
|
|
28
27
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* A feed is a chain of nodes, `feed_N/<plugin>_<ID>/<plugin>_<ID>/…`, and
|
|
29
|
+
* each node keeps its output under `data`. The node is the last
|
|
30
|
+
* `<name>_<ID>` of that chain: the walk starts after `feed_N` and stops at
|
|
31
|
+
* the first `data` folder or at any segment that is not a node's name, so a
|
|
32
|
+
* folder inside a node's output (`data/subject_01`, `data/sub_7/run_2`) is
|
|
33
|
+
* never read as a node, however it is named (#1268).
|
|
31
34
|
*
|
|
32
35
|
* @param dirPath - The directory path to analyze.
|
|
33
36
|
* @returns The plugin instance ID as a number, or null if not found.
|
|
34
37
|
*
|
|
35
38
|
* @example
|
|
36
39
|
* ```typescript
|
|
37
|
-
* // From deep
|
|
38
|
-
* path_extractPluginInstanceID('/home/chris/feeds/feed_123/pl-dircopy_456/data/
|
|
40
|
+
* // From deep inside a node's output
|
|
41
|
+
* path_extractPluginInstanceID('/home/chris/feeds/feed_123/pl-dircopy_456/data/subject_01/')
|
|
39
42
|
* // Returns: 456
|
|
40
43
|
*
|
|
41
|
-
* //
|
|
42
|
-
* path_extractPluginInstanceID('/home/chris/feeds/feed_123/pl-dcm2niix_789/data/')
|
|
44
|
+
* // A child node, from its data directory
|
|
45
|
+
* path_extractPluginInstanceID('/home/chris/feeds/feed_123/pl-dircopy_456/pl-dcm2niix_789/data/')
|
|
43
46
|
* // Returns: 789
|
|
44
47
|
* ```
|
|
45
48
|
*/
|
package/dist/path/chrisPath.js
CHANGED
|
@@ -67,49 +67,45 @@ function path_isInFeed(dirPath) {
|
|
|
67
67
|
return feedPattern.test(dirPath);
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
-
* Extracts the plugin instance ID
|
|
71
|
-
* ancestor directory matching the pattern: <plugin-name>_<instanceID>
|
|
70
|
+
* Extracts the plugin instance ID of the feed node a path is in.
|
|
72
71
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
72
|
+
* A feed is a chain of nodes, `feed_N/<plugin>_<ID>/<plugin>_<ID>/…`, and
|
|
73
|
+
* each node keeps its output under `data`. The node is the last
|
|
74
|
+
* `<name>_<ID>` of that chain: the walk starts after `feed_N` and stops at
|
|
75
|
+
* the first `data` folder or at any segment that is not a node's name, so a
|
|
76
|
+
* folder inside a node's output (`data/subject_01`, `data/sub_7/run_2`) is
|
|
77
|
+
* never read as a node, however it is named (#1268).
|
|
75
78
|
*
|
|
76
79
|
* @param dirPath - The directory path to analyze.
|
|
77
80
|
* @returns The plugin instance ID as a number, or null if not found.
|
|
78
81
|
*
|
|
79
82
|
* @example
|
|
80
83
|
* ```typescript
|
|
81
|
-
* // From deep
|
|
82
|
-
* path_extractPluginInstanceID('/home/chris/feeds/feed_123/pl-dircopy_456/data/
|
|
84
|
+
* // From deep inside a node's output
|
|
85
|
+
* path_extractPluginInstanceID('/home/chris/feeds/feed_123/pl-dircopy_456/data/subject_01/')
|
|
83
86
|
* // Returns: 456
|
|
84
87
|
*
|
|
85
|
-
* //
|
|
86
|
-
* path_extractPluginInstanceID('/home/chris/feeds/feed_123/pl-dcm2niix_789/data/')
|
|
88
|
+
* // A child node, from its data directory
|
|
89
|
+
* path_extractPluginInstanceID('/home/chris/feeds/feed_123/pl-dircopy_456/pl-dcm2niix_789/data/')
|
|
87
90
|
* // Returns: 789
|
|
88
91
|
* ```
|
|
89
92
|
*/
|
|
90
93
|
function path_extractPluginInstanceID(dirPath) {
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return instanceID;
|
|
103
|
-
}
|
|
104
|
-
// Move up one directory
|
|
105
|
-
const parent = path.dirname(currentPath);
|
|
106
|
-
if (parent === currentPath) {
|
|
107
|
-
// Reached root without finding a match
|
|
94
|
+
const nodePattern = /^.+_(\d+)$/;
|
|
95
|
+
const segments = path.normalize(dirPath).split('/').filter((segment) => segment !== '');
|
|
96
|
+
const feedAt = segments.findIndex((segment) => /^feed_\d+$/.test(segment));
|
|
97
|
+
if (feedAt === -1)
|
|
98
|
+
return null;
|
|
99
|
+
let instanceID = null;
|
|
100
|
+
for (const segment of segments.slice(feedAt + 1)) {
|
|
101
|
+
if (segment === 'data')
|
|
102
|
+
break;
|
|
103
|
+
const match = segment.match(nodePattern);
|
|
104
|
+
if (match === null)
|
|
108
105
|
break;
|
|
109
|
-
|
|
110
|
-
currentPath = parent;
|
|
106
|
+
instanceID = parseInt(match[1], 10);
|
|
111
107
|
}
|
|
112
|
-
return
|
|
108
|
+
return instanceID;
|
|
113
109
|
}
|
|
114
110
|
/**
|
|
115
111
|
* Extracts the feed ID from a path.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chrisPath.js","sourceRoot":"","sources":["../../src/path/chrisPath.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBH,sCAIC;
|
|
1
|
+
{"version":3,"file":"chrisPath.js","sourceRoot":"","sources":["../../src/path/chrisPath.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;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SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,mDAAmD;QACnD,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED,SAAS,CAAC,IAAI,CAAC,CAAC,CAAkB,EAAE,CAAkB,EAAE,EAAE;QACxD,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;YAAE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;QAClD,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;YAAE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;QAClD,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fnndsc/cumin",
|
|
3
|
-
"version": "3.29.
|
|
3
|
+
"version": "3.29.3",
|
|
4
4
|
"description": "Utility library for ChILI and other ChRIS-related JavaScript applications",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -74,6 +74,6 @@
|
|
|
74
74
|
"chalk": "^4.1.2",
|
|
75
75
|
"figlet": "^1.7.0",
|
|
76
76
|
"@fnndsc/fond": "^0.6.0",
|
|
77
|
-
"@fnndsc/menu": "^0.
|
|
77
|
+
"@fnndsc/menu": "^0.31.0"
|
|
78
78
|
}
|
|
79
79
|
}
|