|
| 1 | +/* |
| 2 | + * Copyright 2022 The Kubernetes Authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +const messageForMacOS = "echo MMM" |
| 18 | +const messageForLinux = "echo LLL" |
| 19 | +const messageForWindows = "echo WWW" |
| 20 | + |
| 21 | +const messageForElectron = |
| 22 | + process.platform === "linux" ? messageForLinux : process.platform === "darwin" ? messageForMacOS : messageForWindows |
| 23 | + |
| 24 | +// here, we will squash away the choice |
| 25 | +const importgForElectron: (name: string) => Tree = (name: string) => ({ |
| 26 | + name, |
| 27 | + children: [{ name: messageForElectron }], |
| 28 | +}) |
| 29 | + |
| 30 | +// here, we won't squash away the choice |
| 31 | +const importgForBrowser: (name: string) => Tree = (name: string) => ({ |
| 32 | + name, |
| 33 | + children: [ |
| 34 | + { name: "Option 1: MacOS", children: [{ name: messageForMacOS }] }, |
| 35 | + { name: "Option 2: Linux", children: [{ name: messageForLinux }] }, |
| 36 | + { name: "Option 3: Windows", children: [{ name: messageForWindows }] }, |
| 37 | + ], |
| 38 | +}) |
| 39 | + |
| 40 | +const importg: (name?: string) => Tree = (name = "importg") => |
| 41 | + (process.env.MOCHA_RUN_TARGET || "electron") === "electron" ? importgForElectron(name) : importgForBrowser(name) |
| 42 | + |
| 43 | +export default importg |
0 commit comments