itty-packager 1.0.1 → 1.0.2
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.
- package/lib/commands/lint.js +20 -9
- package/package.json +1 -1
package/lib/commands/lint.js
CHANGED
|
@@ -84,11 +84,16 @@ Note:
|
|
|
84
84
|
fs.existsSync(path.join(cwd, file))
|
|
85
85
|
)
|
|
86
86
|
|
|
87
|
-
// Find itty-packager's
|
|
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 node_modules) or published (use npx)
|
|
92
|
+
const isDevMode = await fs.pathExists(path.join(packagerPath, 'node_modules'))
|
|
93
|
+
const eslintBinary = isDevMode
|
|
94
|
+
? path.join(packagerPath, 'node_modules', '.bin', 'eslint')
|
|
95
|
+
: 'eslint' // Use npx approach for published version
|
|
96
|
+
|
|
92
97
|
const eslintArgs = []
|
|
93
98
|
|
|
94
99
|
// Use built-in config if no local config exists
|
|
@@ -134,17 +139,23 @@ Note:
|
|
|
134
139
|
|
|
135
140
|
console.log(`🔍 Linting with ESLint...`)
|
|
136
141
|
|
|
137
|
-
// Run ESLint
|
|
142
|
+
// Run ESLint
|
|
138
143
|
return new Promise((resolve, reject) => {
|
|
139
|
-
const
|
|
144
|
+
const useNpx = !isDevMode
|
|
145
|
+
const command = useNpx ? 'npx' : eslintBinary
|
|
146
|
+
const args = useNpx ? ['eslint', ...eslintArgs] : eslintArgs
|
|
147
|
+
|
|
148
|
+
// Set up environment with access to itty-packager's node_modules for ESLint plugins
|
|
149
|
+
const env = {
|
|
150
|
+
...process.env,
|
|
151
|
+
NODE_PATH: `${path.join(packagerPath, 'node_modules')}:${process.env.NODE_PATH || ''}`
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const eslint = spawn(command, args, {
|
|
140
155
|
stdio: 'inherit',
|
|
141
156
|
cwd: process.cwd(),
|
|
142
157
|
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
|
-
}
|
|
158
|
+
env
|
|
148
159
|
})
|
|
149
160
|
|
|
150
161
|
eslint.on('close', (code) => {
|