codify-plugin-lib 1.0.163 → 1.0.164

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.
@@ -4,9 +4,19 @@ import { addVariablesToPath, areArraysEqual, resolvePathWithVariables, tildify,
4
4
  const ParameterEqualsDefaults = {
5
5
  'boolean': (a, b) => Boolean(a) === Boolean(b),
6
6
  'directory': (a, b) => {
7
+ let transformedA = resolvePathWithVariables(untildify(String(a)));
8
+ let transformedB = resolvePathWithVariables(untildify(String(b)));
9
+ if (transformedA.startsWith('.')) { // Only relative paths start with '.'
10
+ transformedA = path.resolve(transformedA);
11
+ }
12
+ if (transformedB.startsWith('.')) { // Only relative paths start with '.'
13
+ transformedB = path.resolve(transformedB);
14
+ }
7
15
  const notCaseSensitive = process.platform === 'darwin';
8
- const transformedA = path.resolve(resolvePathWithVariables(untildify(notCaseSensitive ? String(a).toLowerCase() : String(a))));
9
- const transformedB = path.resolve(resolvePathWithVariables(untildify(notCaseSensitive ? String(b).toLowerCase() : String(b))));
16
+ if (notCaseSensitive) {
17
+ transformedA = transformedA.toLowerCase();
18
+ transformedB = transformedB.toLowerCase();
19
+ }
10
20
  return transformedA === transformedB;
11
21
  },
12
22
  'number': (a, b) => Number(a) === Number(b),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.163",
3
+ "version": "1.0.164",
4
4
  "description": "Library plugin library",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -381,7 +381,9 @@ ${JSON.stringify(refresh, null, 2)}
381
381
  }
382
382
  }
383
383
 
384
- private async applyTransformParameters(config: Partial<T> | null, reverse?: { original: Partial<T> | null }): Promise<void> {
384
+ private async applyTransformParameters(config: Partial<T> | null, reverse?: {
385
+ original: Partial<T> | null
386
+ }): Promise<void> {
385
387
  if (!config) {
386
388
  return;
387
389
  }
@@ -1119,4 +1119,30 @@ describe('Resource parameter tests', () => {
1119
1119
  propB: 'random2',
1120
1120
  })).to.be.false;
1121
1121
  })
1122
+
1123
+ it('Can match directories 1', async () => {
1124
+ const resource = new class extends TestResource {
1125
+ getSettings(): ResourceSettings<TestConfig> {
1126
+ return {
1127
+ id: 'resourceType',
1128
+ parameterSettings: {
1129
+ propA: { type: 'directory' }
1130
+ },
1131
+ }
1132
+ }
1133
+ };
1134
+
1135
+ const controller = new ResourceController(resource);
1136
+ const transformations = controller.parsedSettings.inputTransformations.propA;
1137
+
1138
+ const to = transformations!.to('$HOME/abc/def')
1139
+ expect(to).to.eq(os.homedir() + '/abc/def')
1140
+
1141
+ const from = transformations!.from(os.homedir() + '/abc/def')
1142
+ expect(from).to.eq('~/abc/def')
1143
+
1144
+ const from2 = transformations!.from(os.homedir() + '/abc/def', '$HOME/abc/def')
1145
+ expect(from2).to.eq('$HOME/abc/def')
1146
+
1147
+ })
1122
1148
  })
@@ -313,9 +313,22 @@ export interface StatefulParameterSetting extends DefaultParameterSetting {
313
313
  const ParameterEqualsDefaults: Partial<Record<ParameterSettingType, (a: unknown, b: unknown) => boolean>> = {
314
314
  'boolean': (a: unknown, b: unknown) => Boolean(a) === Boolean(b),
315
315
  'directory': (a: unknown, b: unknown) => {
316
+ let transformedA = resolvePathWithVariables(untildify(String(a)))
317
+ let transformedB = resolvePathWithVariables(untildify(String(b)))
318
+
319
+ if (transformedA.startsWith('.')) { // Only relative paths start with '.'
320
+ transformedA = path.resolve(transformedA)
321
+ }
322
+
323
+ if (transformedB.startsWith('.')) { // Only relative paths start with '.'
324
+ transformedB = path.resolve(transformedB)
325
+ }
326
+
316
327
  const notCaseSensitive = process.platform === 'darwin';
317
- const transformedA = path.resolve(resolvePathWithVariables(untildify(notCaseSensitive ? String(a).toLowerCase() : String(a))))
318
- const transformedB = path.resolve(resolvePathWithVariables(untildify(notCaseSensitive ? String(b).toLowerCase() : String(b))))
328
+ if (notCaseSensitive) {
329
+ transformedA = transformedA.toLowerCase();
330
+ transformedB = transformedB.toLowerCase();
331
+ }
319
332
 
320
333
  return transformedA === transformedB;
321
334
  },