Skip to content

Commit

Permalink
Update execSync command to use 'node' instead of 'tsx'
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Feb 6, 2024
1 parent 4d91570 commit 4f1d4db
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 82 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type-check": "cross-env NODE_OPTIONS=--max-old-space-size=16384 pnpm --filter \"./packages/*\" --parallel type-check",
"commit-check": "commitlint --from=HEAD~1 --verbose",
"dev": "cross-env NODE_OPTIONS=--max-old-space-size=16384 pnpm --filter \"./packages/*\" dev",
"clean": "rm -rf node_modules && rm -rf package-lock.json && rm -rf **/*package-lock.json && rm -rf **/*node_modules && rm -rf **/*dist && rm -rf **/*.turbo"
"clean": "rm -rf node_modules && rm -rf pnpm-lock.json && rm -rf **/*pnpm-lock.json && rm -rf **/*node_modules && rm -rf **/*dist"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
35 changes: 16 additions & 19 deletions packages/css/src/bin/index.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
#!/usr/bin/env node

import { Command } from 'commander'
import path from 'path'
import fs from 'fs'
// @ts-expect-error
import CONFIG_TEXT from '../master.css.js.txt'
// @ts-expect-error
import CONFIG_ESM_TEXT from '../master.css.mjs.txt'
// @ts-expect-error
import CONFIG_TS_TEXT from '../master.css.ts.txt'
import log from '@techor/log'
import { readJSONFileSync } from '@techor/fs'

const { version, name, description } = readJSONFileSync(path.resolve(__dirname, '../../package.json'))
const { Command } = require('commander')
const path = require('path')
const fs = require('fs')
const log = require('@techor/log')
const { readJSONFileSync } = require('@techor/fs')
const pkg = readJSONFileSync(path.resolve(__dirname, '../../package.json'))
const program = new Command()

const CONFIG_ESM_TEXT = require('../master.css.mjs.txt')
const CONFIG_TS_TEXT = require('../master.css.ts.txt')
const CONFIG_TEXT = require('../master.css.js.txt')

program
.name(name)
.description(description)
.version(version || '0.0.0')
.name(pkg.name)
.description(pkg.description)
.version(pkg.version || '0.0.0')

program.command('init')
.description('Initialize definition files for Master CSS')
.option('-o, --override', 'Override existing definition file')
.option('--esm', 'ES Module .mjs')
.option('--ts', 'TypeScript .ts')
.option('--cjs', 'CommonJS .js')
.action(async function (options) {
.action(async function (options: { override?: any; esm?: any; ts?: any; cjs?: any }) {
let { esm, ts, cjs } = options
// automatically detect the format
if (!esm && !ts && !cjs) {
Expand Down Expand Up @@ -68,7 +65,7 @@ program.command('render')
.argument('<source paths>', 'The path in glob patterns of the source of the HTML file')
.option('-c --config <path>', 'The source path of the Master CSS configuration', 'master.css.*')
.option('-a --analyze', 'Analyze injected CSS and HTML size ( brotli ) without writing to file')
.action(async function (args, options) {
.action(async function (args: any, options: any) {
try {
const action = require('@master/css-renderer/actions/main')
await action(args, options)
Expand All @@ -88,7 +85,7 @@ program.command('extract')
.option('-v, --verbose <level>', 'Verbose logging 0~N', '1')
.option('--no-export', 'Print only CSS results.')
.option('--options <path>', 'Specify your extractor options sources', 'master.css-extractor.*')
.action(async function (args, options) {
.action(async function (args: any, options: any) {
try {
const action = require('@master/css-extractor/actions/main')
await action(args, options)
Expand Down
2 changes: 1 addition & 1 deletion packages/css/tests/cjs/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import normalizeNewline from 'normalize-newline'
it('init cjs', () => {
const configFilepath = resolve(__dirname, 'master.css.js')
rm(configFilepath)
execSync('tsx ../../dist/bin/index.bundle.js init', { cwd: __dirname, stdio: 'inherit' })
execSync('node ../../dist/bin/index.bundle.js init', { cwd: __dirname, stdio: 'inherit' })
expect(normalizeNewline(readFileSync(configFilepath, 'utf-8'))).toEqual(normalizeNewline(require('../../src/master.css.js.txt')))
rm(configFilepath)
})
2 changes: 1 addition & 1 deletion packages/css/tests/esm/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import normalizeNewline from 'normalize-newline'
it('init (type="module")', () => {
const configFilepath = resolve(__dirname, 'master.css.mjs')
rm(configFilepath)
execSync('tsx ../../dist/bin/index.bundle.js init', { cwd: __dirname, stdio: 'inherit' })
execSync('node ../../dist/bin/index.bundle.js init', { cwd: __dirname, stdio: 'inherit' })
expect(normalizeNewline(readFileSync(configFilepath, 'utf-8'))).toEqual(normalizeNewline(require('../../src/master.css.mjs.txt')))
rm(configFilepath)
})
2 changes: 1 addition & 1 deletion packages/css/tests/ts/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import normalizeNewline from 'normalize-newline'
it('init by tsconfig.json', () => {
const configFilepath = resolve(__dirname, 'master.css.ts')
rm(configFilepath)
execSync('tsx ../../dist/bin/index.bundle.js init', { cwd: __dirname, stdio: 'inherit' })
execSync('node ../../dist/bin/index.bundle.js init', { cwd: __dirname })
expect(normalizeNewline(readFileSync(configFilepath, 'utf-8'))).toEqual(normalizeNewline(require('../../src/master.css.ts.txt')))
rm(configFilepath)
})
Loading

0 comments on commit 4f1d4db

Please sign in to comment.