@codeandmoney/jargal 0.0.2-RC.3 → 0.0.2-RC.5
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/actions/write.ts +7 -7
- package/deno.json +1 -1
- package/package.json +1 -1
- package/runner.ts +1 -1
package/actions/write.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// TODO: get rid of `node:` imports and "del", "mkdirp" libraries
|
|
2
|
-
import { access } from "node:fs/promises"
|
|
2
|
+
import { access, mkdir, rm, writeFile } from "node:fs/promises"
|
|
3
3
|
|
|
4
4
|
import { dirname } from "@std/path"
|
|
5
5
|
|
|
@@ -24,12 +24,12 @@ export type WriteActionConfig = {
|
|
|
24
24
|
|
|
25
25
|
export function write( config: WriteActionConfig ): Action {
|
|
26
26
|
return async function execute() {
|
|
27
|
-
await
|
|
27
|
+
await mkdir( dirname( config.destination ), { recursive: true } )
|
|
28
28
|
|
|
29
29
|
let doesExist = await fileExists( config.destination )
|
|
30
30
|
|
|
31
31
|
if ( doesExist && config.mode === "force" ) {
|
|
32
|
-
await
|
|
32
|
+
await rm( config.destination, { recursive: true } )
|
|
33
33
|
doesExist = false
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -42,7 +42,7 @@ export function write( config: WriteActionConfig ): Action {
|
|
|
42
42
|
return
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
await
|
|
45
|
+
await writeFile( config.destination, new TextEncoder().encode( config.content ) )
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// if(eager) {
|
|
@@ -51,7 +51,7 @@ export function write( config: WriteActionConfig ): Action {
|
|
|
51
51
|
// return execute
|
|
52
52
|
// }
|
|
53
53
|
// return async ( params ) => {
|
|
54
|
-
// await
|
|
54
|
+
// await mkdir( dirname( config.destination ), { recursive: true } )
|
|
55
55
|
|
|
56
56
|
// // const template = ( await readFile( config.template ) ).toString()
|
|
57
57
|
|
|
@@ -60,7 +60,7 @@ export function write( config: WriteActionConfig ): Action {
|
|
|
60
60
|
// const doesExist = await fileExists( config.destination )
|
|
61
61
|
|
|
62
62
|
// if ( doesExist && config.writeMode === "force" ) {
|
|
63
|
-
// await
|
|
63
|
+
// await remove( config.destination, { recursive: true } )
|
|
64
64
|
// }
|
|
65
65
|
|
|
66
66
|
// if ( doesExist ) {
|
|
@@ -72,7 +72,7 @@ export function write( config: WriteActionConfig ): Action {
|
|
|
72
72
|
// throw `File already exists\n -> ${config.destination}`
|
|
73
73
|
// }
|
|
74
74
|
|
|
75
|
-
// await
|
|
75
|
+
// await writeFile( config.destination, new TextEncoder().encode( rendered ) )
|
|
76
76
|
// }
|
|
77
77
|
}
|
|
78
78
|
|
package/deno.json
CHANGED
package/package.json
CHANGED
package/runner.ts
CHANGED
|
@@ -19,7 +19,7 @@ export async function executeAction(
|
|
|
19
19
|
): Promise<void | Action | Action[]> {
|
|
20
20
|
if ( Array.isArray( action ) ) {
|
|
21
21
|
for ( const action_ of action ) {
|
|
22
|
-
await executeAction( { action: action_, context, renderer } )
|
|
22
|
+
return await executeAction( { action: action_, context, renderer } )
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|