Skip to content

Commit

Permalink
feat: support wdio/wdi5 in typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
vobu committed Jul 2, 2022
1 parent 023ca0b commit c363ab0
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gray, greenBright } from "colorette"
import { execSync } from "child_process"
import { copyFile } from "fs/promises"
import { copyFile, cp } from "fs/promises"

const DEV_DEPS = [
"@wdio/cli",
Expand All @@ -12,7 +12,13 @@ const DEV_DEPS = [
"chromedriver"
]

const DEV_DEPS_TS = [...DEV_DEPS, "ts-node", "typescript"]

export async function run() {
process.argv.find((arg) => arg.includes("ts")) ? await initTS() : await initJS()
}

async function initJS() {
console.log(gray("≡> copying wdio.conf.js into place..."))
await copyFile(`${__dirname}/../templates/wdio.conf.js`, `${process.cwd()}/wdio.conf.js`)
console.log(greenBright("👍 done!"))
Expand All @@ -21,7 +27,21 @@ export async function run() {
execSync(`npm i ${DEV_DEPS.join(" ")} --save-dev`, { stdio: "inherit" })
console.log(greenBright("👍 done!"))

console.log(gray("≡> adding wdi5 start command to package.json..."))
console.log(gray('≡> adding wdi5 start command ("wdi5") to package.json...'))
execSync(`npm set-script wdi5 "wdio run wdio.conf.js"`, { stdio: "inherit" })
console.log(greenBright("👍 done!"))
}

async function initTS() {
console.log(gray('≡> copying tsconfig.json + wdio.conf.ts into "./test/"...'))
await cp(`${__dirname}/../templates/test`, `${process.cwd()}/test`, { recursive: true })
console.log(greenBright("👍 done!"))

console.log(gray("≡> installing wdio + wdi5 and adding them as dev dependencies..."))
execSync(`npm i ${DEV_DEPS_TS.join(" ")} --save-dev`, { stdio: "inherit" })
console.log(greenBright("👍 done!"))

console.log(gray("≡> adding wdi5 start command to package.json..."))
execSync(`npm set-script wdi5 "wdio run test/wdio.conf.ts"`, { stdio: "inherit" })
console.log(greenBright("👍 done!"))
}

0 comments on commit c363ab0

Please sign in to comment.