@sphido/core 2.0.1 → 2.0.4

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.
@@ -0,0 +1,18 @@
1
+ import {mkdir, copyFile as copyFileSync} from 'node:fs/promises';
2
+ import {existsSync} from 'node:fs';
3
+ import {dirname} from 'node:path';
4
+
5
+ /**
6
+ * Write content to the file and create directory if not exists
7
+ *
8
+ * @param {string} file
9
+ * @param {string} content
10
+ * @returns {Promise<*>}
11
+ */
12
+ export async function copyFile(src, dest) {
13
+ if (!existsSync(dirname(src))) {
14
+ await mkdir(dirname(src), {recursive: true});
15
+ }
16
+
17
+ return copyFileSync(src, dest);
18
+ }
package/lib/get-pages.js CHANGED
@@ -14,14 +14,14 @@ export async function getPages({path = 'content', include = isPage} = {}, ...ext
14
14
 
15
15
  return Promise.all(
16
16
  dir
17
- .filter(dirent => include(dirent))
17
+ .filter(dirent => include(dirent, path))
18
18
  .map(async dirent => {
19
19
  // Page
20
20
  const page = {name: parse(dirent.name).name, path: join(path, dirent.name)};
21
21
 
22
22
  // Read subdirectory recursively
23
23
  if (dirent.isDirectory()) {
24
- page.children = await getPages({path: page.path, isPage: include}, ...extenders);
24
+ page.children = await getPages({path: page.path, include}, ...extenders);
25
25
  }
26
26
 
27
27
  // Calling callbacks
package/lib/index.js CHANGED
@@ -2,3 +2,4 @@ export {getPages} from './get-pages.js';
2
2
  export {allPages} from './all-pages.js';
3
3
  export {readFile} from './read-file.js';
4
4
  export {writeFile} from './write-file.js';
5
+ export {copyFile} from './copy-file.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphido/core",
3
- "version": "2.0.1",
3
+ "version": "2.0.4",
4
4
  "author": {
5
5
  "name": "Roman Ožana",
6
6
  "email": "roman@ozana.cz",
@@ -40,5 +40,5 @@
40
40
  "scripts": {
41
41
  "test": "ava"
42
42
  },
43
- "gitHead": "75cf4126bc6027237f192873c51c0d636aacd0ab"
43
+ "gitHead": "725a4f04403f90e7b8979c9f2cf881f413e42498"
44
44
  }