-
-
Notifications
You must be signed in to change notification settings - Fork 201
Expand file tree
/
Copy pathconfig-transformer.ts
More file actions
62 lines (54 loc) · 1.63 KB
/
config-transformer.ts
File metadata and controls
62 lines (54 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { assert } from "chai";
import { ConfigTransformer } from "../../../lib/tools/config-manipulation/config-transformer";
describe("ConfigTransformer", () => {
it("updates existing boolean literals", () => {
const content = `export default {
id: 'org.nativescript.myapp',
discardUncaughtJsExceptions: true,
} as any;`;
const transformer = new ConfigTransformer(content);
const updated = transformer.setValue("discardUncaughtJsExceptions", false);
const updatedTransformer = new ConfigTransformer(updated);
assert.strictEqual(
updatedTransformer.getValue("discardUncaughtJsExceptions"),
false,
);
});
it("updates existing ios.SPMPackages array literals", () => {
const content = `import { NativeScriptConfig } from '@nativescript/core'
export default {
id: 'org.nativescript.myapp',
ios: {
SPMPackages: [
{
name: 'RiveRuntime',
libs: ['RiveRuntime'],
repositoryURL: 'https://github.com/rive-app/rive-ios.git',
version: '6.11.0',
},
],
},
} as NativeScriptConfig`;
const spmPackages = [
{
name: "RiveRuntime",
libs: ["RiveRuntime"],
repositoryURL: "https://github.com/rive-app/rive-ios.git",
version: "6.11.0",
},
{
name: "SharedWidget",
libs: ["SharedWidget"],
path: "./Shared_Resources/iOS/SharedWidget",
targets: ["widget"],
},
];
const transformer = new ConfigTransformer(content);
const updated = transformer.setValue("ios.SPMPackages", spmPackages);
const updatedTransformer = new ConfigTransformer(updated);
assert.deepStrictEqual(
updatedTransformer.getValue("ios.SPMPackages"),
spmPackages,
);
});
});