esm-styles 0.1.5 → 0.1.7

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.
Files changed (2) hide show
  1. package/dist/watch.js +37 -0
  2. package/package.json +3 -2
package/dist/watch.js ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from 'child_process'
3
+ import path from 'path'
4
+ import process from 'process'
5
+
6
+ const configPath = process.argv[2] || 'esm-styles.config.js'
7
+ const configModule = await import(
8
+ path.isAbsolute(configPath)
9
+ ? configPath
10
+ : path.resolve(process.cwd(), configPath)
11
+ )
12
+ const config = configModule.default
13
+
14
+ const basePath = path.resolve(process.cwd(), config.basePath || '.')
15
+ const sourcePath = path.join(basePath, config.sourcePath || '')
16
+
17
+ const buildJsPath = path.resolve(
18
+ path.dirname(new URL(import.meta.url).pathname),
19
+ 'build.js'
20
+ )
21
+
22
+ const nodemonArgs = [
23
+ '--watch',
24
+ sourcePath,
25
+ '--ext',
26
+ 'mjs',
27
+ '--ignore',
28
+ path.join(sourcePath, '$*.mjs'),
29
+ '--exec',
30
+ `node ${buildJsPath} ${configPath}`,
31
+ ]
32
+
33
+ console.log('[esm-styles] Running:', 'nodemon', ...nodemonArgs)
34
+
35
+ const nodemon = spawn('nodemon', nodemonArgs, { stdio: 'inherit' })
36
+
37
+ nodemon.on('exit', (code) => process.exit(code))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esm-styles",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "A library for working with ESM styles",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,7 +29,8 @@
29
29
  "node": ">=14.16"
30
30
  },
31
31
  "bin": {
32
- "build": "dist/build.js"
32
+ "build": "dist/build.js",
33
+ "watch": "dist/watch.js"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@types/jest": "^29.5.14",