This repository was archived by the owner on Jan 30, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +22
-48
lines changed
Expand file tree Collapse file tree 4 files changed +22
-48
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env node
22
3+ const { findNextJsProjectRoot } = require ( '../src/_internal' ) ;
34const { execSync } = require ( 'child_process' ) ;
4- const { join, dirname } = require ( 'path' ) ;
5- const { existsSync } = require ( 'fs' ) ;
6-
7- function findNextJsProjectRoot ( startPath ) {
8- let currentPath = startPath ;
9- while ( currentPath !== '/' ) {
10- if (
11- existsSync ( join ( currentPath , 'package.json' ) ) &&
12- ( existsSync ( join ( currentPath , 'next.config.js' ) ) || existsSync ( join ( currentPath , 'next.config.mjs' ) ) )
13- ) {
14- return currentPath ;
15- }
16- currentPath = dirname ( currentPath ) ;
17- }
18- return null ;
19- }
5+ const { join } = require ( 'path' ) ;
206
217if ( process . argv . includes ( '--compile' ) ) {
228 try {
@@ -26,7 +12,7 @@ if (process.argv.includes('--compile')) {
2612 }
2713
2814 console . log ( 'Running TypeScript compiler...' ) ;
29- execSync ( 'npx tsc --noEmit' , {
15+ execSync ( 'npx tsc --noEmit compiler/src/index.ts ' , {
3016 stdio : 'inherit' ,
3117 cwd : join ( packageRoot , 'node_modules/typedcssx' ) ,
3218 } ) ;
Original file line number Diff line number Diff line change 1+ import { findNextJsProjectRoot } from '../../src/_internal' ;
12import { existsSync , writeFileSync } from 'fs' ;
2- import { join , dirname } from 'path' ;
3-
4- function findNextJsProjectRoot ( startPath : string ) : string | null {
5- let currentPath = startPath ;
6- while ( currentPath !== '/' ) {
7- if (
8- existsSync ( join ( currentPath , 'package.json' ) ) &&
9- ( existsSync ( join ( currentPath , 'next.config.js' ) ) || existsSync ( join ( currentPath , 'next.config.mjs' ) ) )
10- ) {
11- return currentPath ;
12- }
13- currentPath = dirname ( currentPath ) ;
14- }
15- return null ;
16- }
3+ import { join } from 'path' ;
174
185export const cleanUp = async ( ) => {
196 const projectRoot = findNextJsProjectRoot ( __dirname ) ;
Original file line number Diff line number Diff line change 11'use server' ;
22
33import { readFileSync , appendFileSync , mkdirSync , existsSync } from 'fs' ;
4- import { isServer } from './helper' ;
5- import { join , dirname } from 'path' ;
6-
7- function findNextJsProjectRoot ( startPath : string ) : string | null {
8- let currentPath = startPath ;
9- while ( currentPath !== '/' ) {
10- if (
11- existsSync ( join ( currentPath , 'package.json' ) ) &&
12- ( existsSync ( join ( currentPath , 'next.config.js' ) ) || existsSync ( join ( currentPath , 'next.config.mjs' ) ) )
13- ) {
14- return currentPath ;
15- }
16- currentPath = dirname ( currentPath ) ;
17- }
18- return null ;
19- }
4+ import { findNextJsProjectRoot , isServer } from './helper' ;
5+ import { join } from 'path' ;
206
217export const buildIn = ( styleSheet : string , global ?: string ) => {
228 const projectRoot = findNextJsProjectRoot ( __dirname ) ;
Original file line number Diff line number Diff line change 11import * as path from 'path' ;
2+ import * as fs from 'fs' ;
23import type { ClassesObjectType , HasEPE , HasECE } from '..' ;
34import htmlTags from './html-tags' ;
45
6+ export function findNextJsProjectRoot ( startPath : string ) : string | null {
7+ let currentPath = startPath ;
8+ while ( currentPath !== '/' ) {
9+ if (
10+ fs . existsSync ( path . join ( currentPath , 'package.json' ) ) &&
11+ ( fs . existsSync ( path . join ( currentPath , 'next.config.js' ) ) || fs . existsSync ( path . join ( currentPath , 'next.config.mjs' ) ) )
12+ ) {
13+ return currentPath ;
14+ }
15+ currentPath = path . dirname ( currentPath ) ;
16+ }
17+ return null ;
18+ }
19+
520const isWindowDefined = typeof window !== 'undefined' ;
621const isDocumentDefined = typeof document !== 'undefined' ;
722export const isServer = ! isWindowDefined || ! isDocumentDefined ;
You can’t perform that action at this time.
0 commit comments