Skip to content

Commit

Permalink
Update execSync to execaCommandSync in test files
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Feb 23, 2024
1 parent 5d60e3e commit 160de4e
Show file tree
Hide file tree
Showing 13 changed files with 400 additions and 3,484 deletions.
4 changes: 2 additions & 2 deletions packages/create/tests/cjs/test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { execSync } from 'node:child_process'
import { execaCommandSync } from 'execa'
import { join } from 'node:path'
import { readFileSync } from 'node:fs'
import { rm } from 'css-shared/utils/fs'

it('init cjs', () => {
rm(join(__dirname, 'master.css.js'))
execSync('tsx ../../src/bin', { cwd: __dirname })
execaCommandSync('tsx ../../src/bin', { cwd: __dirname })
expect(readFileSync(join(__dirname, 'master.css.js'), 'utf-8')).toEqual(require('../../src/master.css.js.js').default)
})
4 changes: 2 additions & 2 deletions packages/create/tests/esm/test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { execSync } from 'node:child_process'
import { execaCommandSync } from 'execa'
import { join } from 'node:path'
import { readFileSync } from 'node:fs'
import { rm } from 'css-shared/utils/fs'

it('init (type="module")', () => {
rm(join(__dirname, 'master.css.mjs'))
execSync('tsx ../../src/bin', { cwd: __dirname })
execaCommandSync('tsx ../../src/bin', { cwd: __dirname })
expect(readFileSync(join(__dirname, 'master.css.mjs'), 'utf-8')).toEqual(require('../../src/master.css.mjs.js').default)
})
4 changes: 2 additions & 2 deletions packages/create/tests/new/test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { execSync } from 'node:child_process'
import { execaCommandSync } from 'execa'
import { rm } from 'css-shared/utils/fs'
import { join } from 'node:path'
import { existsSync, readFileSync } from 'node:fs'

it('creates a new app', () => {
rm(join(__dirname, 'my-app'))
execSync('tsx ../../src/bin my-app', { cwd: __dirname })
execaCommandSync('tsx ../../src/bin my-app', { cwd: __dirname })
expect(existsSync(join(__dirname, 'my-app/package.json'))).toBe(true)
})

Expand Down
4 changes: 2 additions & 2 deletions packages/create/tests/nextjs/test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { execSync } from 'node:child_process'
import { execaCommandSync } from 'execa'
import { rm } from 'css-shared/utils/fs'
import { join } from 'node:path'
import { existsSync } from 'node:fs'

it('creates a new app', () => {
rm(join(__dirname, 'master.css.ts'))
execSync('tsx ../../src/bin', { cwd: __dirname })
execaCommandSync('tsx ../../src/bin', { cwd: __dirname })
expect(existsSync(join(__dirname, 'master.css.ts'))).toBe(true)
})
4 changes: 2 additions & 2 deletions packages/create/tests/ts/test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { execSync } from 'node:child_process'
import { execaCommandSync } from 'execa'
import { join } from 'node:path'
import { readFileSync } from 'node:fs'
import { rm } from 'css-shared/utils/fs'

it('init by tsconfig.json', () => {
rm(join(__dirname, 'master.css.ts'))
execSync('tsx ../../src/bin', { cwd: __dirname })
execaCommandSync('tsx ../../src/bin', { cwd: __dirname })
expect(readFileSync(join(__dirname, 'master.css.ts'), 'utf-8')).toEqual(require('../../src/master.css.ts.js').default)
})
4 changes: 2 additions & 2 deletions packages/create/tests/with-deps/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { execSync } from 'node:child_process'
import { execaCommandSync } from 'execa'
import { join } from 'node:path'
import { existsSync, writeFileSync } from 'node:fs'

Expand All @@ -11,6 +11,6 @@ writeFileSync(join(__dirname, 'package.json'), JSON.stringify({
}))

it('init', () => {
execSync('tsx ../../src/bin', { cwd: __dirname })
execaCommandSync('tsx ../../src/bin', { cwd: __dirname })
expect(existsSync(join(__dirname, 'node_modules'))).toBeFalsy()
})
4 changes: 2 additions & 2 deletions packages/create/tests/with-no-deps/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { execSync } from 'node:child_process'
import { execaCommandSync } from 'execa'
import { join } from 'node:path'
import { readFileSync, writeFileSync } from 'node:fs'

Expand All @@ -8,6 +8,6 @@ writeFileSync(join(__dirname, 'package.json'), JSON.stringify({
}))

it('init', () => {
execSync('tsx ../../src/bin', { cwd: __dirname })
execaCommandSync('tsx ../../src/bin', { cwd: __dirname })
expect(JSON.parse(readFileSync(join(__dirname, 'package.json'), 'utf-8')).dependencies['@master/css']).toBeDefined()
})
4 changes: 2 additions & 2 deletions packages/extractor.vite/tests/nuxt.js/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'
import { execSync } from 'child_process'
import { execaCommandSync } from 'execa'
import { copy, rm } from 'css-shared/utils/fs'
import { explorePathSync } from '@techor/glob'

Expand All @@ -9,7 +9,7 @@ const tmpDir = path.join(__dirname, 'tmp/build')

it('build', () => {
copy(examplePath, tmpDir)
execSync('pnpm run build', { cwd: tmpDir, stdio: 'inherit' })
execaCommandSync('pnpm run build', { cwd: tmpDir })
expect(fs.readFileSync(explorePathSync(path.resolve(tmpDir, '.nuxt/dist/client/_nuxt/entry.*.css'))).toString()).toContain('font\\:heavy')
rm(tmpDir)
})
4 changes: 2 additions & 2 deletions packages/extractor.vite/tests/react/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path'
import { execSync } from 'child_process'
import { execaCommandSync } from 'execa'
import { copy, rm } from 'css-shared/utils/fs'
import fs from 'fs'
import { explorePathSync } from '@techor/glob'
Expand All @@ -10,7 +10,7 @@ const tmpDir = path.join(__dirname, 'tmp/build')
test.todo(`Error: Cannot find module '../lib/tsc.js'`)
test.skip('build', () => {
copy(examplePath, tmpDir)
execSync('pnpm run build', { cwd: tmpDir, stdio: 'inherit' })
execaCommandSync('pnpm run build', { cwd: tmpDir })
expect(fs.readFileSync(explorePathSync(path.resolve(tmpDir, 'dist/assets/index-*.css'))).toString()).toContain('font\\:heavy')
rm(tmpDir)
})
4 changes: 2 additions & 2 deletions packages/extractor.vite/tests/svelte/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import fs from 'fs'
import { explorePathSync } from '@techor/glob'
import path from 'upath'
import { execSync } from 'child_process'
import { execaCommandSync } from 'execa'
import { copy, rm } from 'css-shared/utils/fs'

const examplePath = path.join(__dirname, '../../../../examples/svelte-with-static-extraction')
const tmpDir = path.join(__dirname, 'tmp/build')

it('build', () => {
copy(examplePath, tmpDir)
execSync('pnpm run build', { cwd: tmpDir, stdio: 'inherit' })
execaCommandSync('pnpm run build', { cwd: tmpDir })
expect(fs.readFileSync(explorePathSync(path.resolve(tmpDir, '.svelte-kit/output/server/_app/immutable/assets/_layout.*.css'))).toString()).toContain('.mt\\:-2vw{margin-top:-2vw}')
rm(tmpDir)
})
4 changes: 2 additions & 2 deletions packages/extractor.vite/tests/vite/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import fs from 'fs'
import { explorePathSync } from '@techor/glob'
import path from 'path'
import { execSync } from 'child_process'
import { execaCommandSync } from 'execa'
import { copy, rm } from 'css-shared/utils/fs'

const examplePath = path.join(__dirname, '../../../../examples/vite-with-static-extraction')
const tmpDir = path.join(__dirname, 'tmp/build')

it('build', () => {
copy(examplePath, tmpDir)
execSync('pnpm run build', { cwd: tmpDir, stdio: 'inherit' })
execaCommandSync('pnpm run build', { cwd: tmpDir })
expect(fs.readFileSync(explorePathSync(path.resolve(tmpDir, 'dist/assets/index-*.css'))).toString()).toContain('center-content')
rm(tmpDir)
})
4 changes: 2 additions & 2 deletions packages/extractor.vite/tests/vue.js/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'
import { execSync } from 'child_process'
import { execaCommandSync } from 'execa'
import { copy, rm } from 'css-shared/utils/fs'
import { explorePathSync } from '@techor/glob'

Expand All @@ -9,7 +9,7 @@ const tmpDir = path.join(__dirname, 'tmp/build')

it('build', () => {
copy(examplePath, tmpDir)
execSync('pnpm run build', { cwd: tmpDir, stdio: 'inherit' })
execaCommandSync('pnpm run build', { cwd: tmpDir })
expect(fs.readFileSync(explorePathSync(path.resolve(tmpDir, 'dist/assets/index-*.css'))).toString()).toContain('font\\:heavy')
rm(tmpDir)
})
Loading

0 comments on commit 160de4e

Please sign in to comment.