itty-packager 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,11 +84,15 @@ Note:
84
84
  fs.existsSync(path.join(cwd, file))
85
85
  )
86
86
 
87
- // Find itty-packager's ESLint binary and config
87
+ // Find itty-packager's path and config
88
88
  const packagerPath = path.resolve(__dirname, '../../')
89
- const eslintBinary = path.join(packagerPath, 'node_modules', '.bin', 'eslint')
90
89
  const builtinConfig = path.join(packagerPath, 'lib', 'configs', 'eslint.config.mjs')
91
90
 
91
+ // Check if we're in development (has ESLint binary) or published (use npx)
92
+ const eslintBinaryPath = path.join(packagerPath, 'node_modules', '.bin', 'eslint')
93
+ const isDevMode = await fs.pathExists(eslintBinaryPath)
94
+ const eslintBinary = isDevMode ? eslintBinaryPath : 'eslint'
95
+
92
96
  const eslintArgs = []
93
97
 
94
98
  // Use built-in config if no local config exists
@@ -134,17 +138,23 @@ Note:
134
138
 
135
139
  console.log(`🔍 Linting with ESLint...`)
136
140
 
137
- // Run ESLint using itty-packager's binary but from the project directory
141
+ // Run ESLint
138
142
  return new Promise((resolve, reject) => {
139
- const eslint = spawn(eslintBinary, eslintArgs, {
143
+ const useNpx = !isDevMode
144
+ const command = useNpx ? 'npx' : eslintBinary
145
+ const args = useNpx ? ['eslint', ...eslintArgs] : eslintArgs
146
+
147
+ // Set up environment with access to itty-packager's node_modules for ESLint plugins
148
+ const env = {
149
+ ...process.env,
150
+ NODE_PATH: `${path.join(packagerPath, 'node_modules')}:${process.env.NODE_PATH || ''}`
151
+ }
152
+
153
+ const eslint = spawn(command, args, {
140
154
  stdio: 'inherit',
141
155
  cwd: process.cwd(),
142
156
  shell: true,
143
- env: {
144
- ...process.env,
145
- NODE_PATH: path.join(packagerPath, 'node_modules'),
146
- PATH: `${path.join(packagerPath, 'node_modules', '.bin')}:${process.env.PATH}`
147
- }
157
+ env
148
158
  })
149
159
 
150
160
  eslint.on('close', (code) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itty-packager",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Universal build tool for itty libraries",
5
5
  "type": "module",
6
6
  "bin": {