|
1 | 1 | import { existsSync } from "fs"; |
2 | 2 | import { cp } from "fs/promises"; |
3 | 3 | import { join } from "path"; |
4 | | -import { readFile, readToml, writeToml } from "helpers/files"; |
| 4 | +import { |
| 5 | + readFile, |
| 6 | + readJSON, |
| 7 | + readToml, |
| 8 | + writeJSON, |
| 9 | + writeToml, |
| 10 | +} from "helpers/files"; |
5 | 11 | import { detectPackageManager } from "helpers/packageManagers"; |
6 | 12 | import { retry } from "helpers/retry"; |
7 | 13 | import { sleep } from "helpers/sleep"; |
@@ -764,17 +770,22 @@ const runCli = async ( |
764 | 770 | */ |
765 | 771 | const addTestVarsToWranglerToml = async (projectPath: string) => { |
766 | 772 | const wranglerTomlPath = join(projectPath, "wrangler.toml"); |
767 | | - let wranglerToml: JsonMap = {}; |
768 | | - const wranglerTomlExists = existsSync(wranglerTomlPath); |
769 | | - if (wranglerTomlExists) { |
770 | | - wranglerToml = readToml(wranglerTomlPath); |
| 773 | + const wranglerJsonPath = join(projectPath, "wrangler.json"); |
| 774 | + if (existsSync(wranglerTomlPath)) { |
| 775 | + const wranglerToml = readToml(wranglerTomlPath); |
| 776 | + // Add a TEST var to the wrangler.toml |
| 777 | + wranglerToml.vars ??= {}; |
| 778 | + (wranglerToml.vars as JsonMap).TEST = "C3_TEST"; |
| 779 | + |
| 780 | + writeToml(wranglerTomlPath, wranglerToml); |
| 781 | + } else if (existsSync(wranglerJsonPath)) { |
| 782 | + const wranglerJson = readJSON(wranglerJsonPath); |
| 783 | + // Add a TEST var to the wrangler.toml |
| 784 | + wranglerJson.vars ??= {}; |
| 785 | + wranglerJson.vars.TEST = "C3_TEST"; |
| 786 | + |
| 787 | + writeJSON(wranglerJsonPath, wranglerJson); |
771 | 788 | } |
772 | | - |
773 | | - // Add a TEST var to the wrangler.toml |
774 | | - wranglerToml.vars ??= {}; |
775 | | - (wranglerToml.vars as JsonMap).TEST = "C3_TEST"; |
776 | | - |
777 | | - writeToml(wranglerTomlPath, wranglerToml); |
778 | 789 | }; |
779 | 790 |
|
780 | 791 | const verifyDeployment = async ( |
|
0 commit comments