chore(create-playwright): some nits (#9133)

This commit is contained in:
Joel Einbinder 2021-10-13 17:33:44 -04:00 committed by GitHub
parent a885e95646
commit 9d3513ab13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 23 deletions

View file

@ -1,8 +1,9 @@
# This ignores everything by default, except for package.json and LICENSE and README.md.
# See https://docs.npmjs.com/misc/developers
**/*
!/lib/**/* !/lib/**/*
/node_modules/ !index.js
/test-results/
/src/**/* !/assets/**/*
/tests/**/*
/playwright.config.ts
/tsconfig.json
/assets/.eslintrc.js /assets/.eslintrc.js

View file

@ -1,6 +1,7 @@
// Example files here do not need the copyright notice.
module.exports = { module.exports = {
"extends": "../../../.eslintrc.js", 'extends': '../../../.eslintrc.js',
"rules": { 'rules': {
"notice/notice": 0 'notice/notice': 0
} }
}; };

View file

@ -1,10 +1,10 @@
// @ts-check // @ts-check
const { devices } = require('@playwright/test'); const { devices } = require('@playwright/test');
const path = require('path') const path = require('path');
/** /**
* @see https://playwright.dev/docs/test-configuration * @see https://playwright.dev/docs/test-configuration
* @type{import('@playwright/test').PlaywrightTestConfig} * @type {import('@playwright/test').PlaywrightTestConfig}
*/ */
const config = { const config = {
// Timeout per test // Timeout per test

View file

@ -5,7 +5,6 @@
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "create-playwright",
"version": "0.1.7", "version": "0.1.7",
"license": "MIT", "license": "MIT",
"bin": { "bin": {

View file

@ -19,7 +19,7 @@ import fs from 'fs';
import { prompt } from 'enquirer'; import { prompt } from 'enquirer';
import colors from 'ansi-colors'; import colors from 'ansi-colors';
import { executeCommands, createFiles, determinePackageManager, executeTemplate, determineRootDir, Command, languagetoFileExtension } from './utils'; import { executeCommands, createFiles, determinePackageManager, executeTemplate, Command, languagetoFileExtension } from './utils';
export type PromptOptions = { export type PromptOptions = {
testDir: string, testDir: string,
@ -189,7 +189,7 @@ export function commandToRunTests(packageManager: 'npm' | 'yarn', args?: string)
} }
(async () => { (async () => {
const rootDir = determineRootDir(); const rootDir = path.resolve(process.cwd(), process.argv[2] || '');
const generator = new Generator(rootDir); const generator = new Generator(rootDir);
await generator.run(); await generator.run();
})().catch(error => { })().catch(error => {

View file

@ -55,14 +55,6 @@ export async function createFiles(rootDir: string, files: Map<string, string>, f
} }
} }
export function determineRootDir() {
const givenPath = process.argv[2];
if (givenPath)
return path.isAbsolute(givenPath) ? process.argv[2] : path.join(process.cwd(), process.argv[2]);
return process.cwd();
}
export function determinePackageManager(rootDir: string): 'yarn' | 'npm' { export function determinePackageManager(rootDir: string): 'yarn' | 'npm' {
if (fs.existsSync(path.join(rootDir, 'yarn.lock'))) if (fs.existsSync(path.join(rootDir, 'yarn.lock')))
return 'yarn'; return 'yarn';