@tenjuu99/blog 0.2.13 → 0.2.15

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/dir.js CHANGED
@@ -2,6 +2,8 @@ import config from './config.js'
2
2
  import { watchers } from './watcher.js'
3
3
  import fs from 'node:fs'
4
4
  import { styleText } from 'node:util'
5
+ import path from 'path'
6
+ import { fileURLToPath } from 'url';
5
7
 
6
8
  const rootDir = process.cwd()
7
9
  const srcDir = `${rootDir}/${config.src_dir}`
@@ -21,6 +23,8 @@ const watch = {
21
23
  helperDir: `${srcDir}/helper`,
22
24
  jsDir: `${srcDir}/js`,
23
25
  }
26
+ const __filename = fileURLToPath(import.meta.url);
27
+ const packageDirCore = path.dirname(__filename) + '/../packages'
24
28
 
25
29
  let alreadyCached = false
26
30
 
@@ -31,11 +35,14 @@ const cache = () => {
31
35
  if (config.packages) {
32
36
  const packages = config.packages.split(',')
33
37
  packages.forEach(dir => {
34
- if (!fs.existsSync(`${packageDir}/${dir}`)) {
35
- throw new Error(`"${dir}" package does not exist.`)
38
+ if (fs.existsSync(`${packageDirCore}/${dir}`)) {
39
+ console.log(styleText('blue', `[cache] enable core package: ${dir}`))
40
+ fs.cpSync(`${packageDirCore}/${dir}`, cacheDir, { recursive: true })
41
+ }
42
+ if (fs.existsSync(`${packageDir}/${dir}`)) {
43
+ console.log(styleText('blue', `[cache] enable package: ${dir}`))
44
+ fs.cpSync(`${packageDir}/${dir}`, cacheDir, { recursive: true })
36
45
  }
37
- console.log(styleText('blue', `[cache] enable package: ${dir}`))
38
- fs.cpSync(`${packageDir}/${dir}`, cacheDir, { recursive: true })
39
46
  })
40
47
  }
41
48
  fs.cpSync(srcDir, cacheDir, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenjuu99/blog",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "blog template",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -34,7 +34,8 @@
34
34
  "files": [
35
35
  "lib",
36
36
  "bin",
37
- "src-sample"
37
+ "src-sample",
38
+ "packages"
38
39
  ],
39
40
  "publishConfig": {
40
41
  "access": "public"