functionalscript 0.6.0 → 0.6.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/dev/index/module.js +3 -0
- package/dev/module.f.js +1 -1
- package/io/module.f.d.ts +13 -1
- package/io/module.f.js +1 -1
- package/io/module.js +2 -1
- package/io/virtual.f.js +4 -0
- package/package.json +3 -3
- package/path/module.f.js +2 -1
- package/dev/index.js +0 -3
- /package/dev/{index.d.ts → index/module.d.ts} +0 -0
package/dev/module.f.js
CHANGED
|
@@ -33,7 +33,7 @@ export const loadModuleMap = async (io) => {
|
|
|
33
33
|
for (const f of await allFiles(io)) {
|
|
34
34
|
if (f.endsWith('.f.js') ||
|
|
35
35
|
(f.endsWith('.f.ts') && !existsSync(f.substring(0, f.length - 3) + '.js'))) {
|
|
36
|
-
const source = await asyncImport(
|
|
36
|
+
const source = await asyncImport(f);
|
|
37
37
|
map = [...map, [f, source]];
|
|
38
38
|
}
|
|
39
39
|
}
|
package/io/module.f.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ export type Dirent = {
|
|
|
13
13
|
readonly isDirectory: () => boolean;
|
|
14
14
|
readonly isFile: () => boolean;
|
|
15
15
|
};
|
|
16
|
+
export type RmOptions = {
|
|
17
|
+
readonly force?: boolean;
|
|
18
|
+
readonly recursive?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type MakeDirectoryOptions = {
|
|
21
|
+
readonly recursive?: boolean;
|
|
22
|
+
};
|
|
16
23
|
/**
|
|
17
24
|
* File system operations interface
|
|
18
25
|
* @see https://nodejs.org/api/fs.html
|
|
@@ -27,6 +34,9 @@ export type Fs = {
|
|
|
27
34
|
readonly readdir: (path: string, options: {
|
|
28
35
|
withFileTypes: true;
|
|
29
36
|
}) => Promise<Dirent[]>;
|
|
37
|
+
readonly rm: (path: string, options?: RmOptions) => Promise<void>;
|
|
38
|
+
readonly mkdir: (path: string, options?: MakeDirectoryOptions) => Promise<string | undefined>;
|
|
39
|
+
readonly copyFile: (src: string, dest: string) => Promise<void>;
|
|
30
40
|
};
|
|
31
41
|
};
|
|
32
42
|
/**
|
|
@@ -70,6 +80,7 @@ export type Process = {
|
|
|
70
80
|
readonly argv: string[];
|
|
71
81
|
readonly env: Env;
|
|
72
82
|
readonly exit: (code: number) => never;
|
|
83
|
+
readonly cwd: () => string;
|
|
73
84
|
};
|
|
74
85
|
/**
|
|
75
86
|
* The environment variables.
|
|
@@ -77,7 +88,8 @@ export type Process = {
|
|
|
77
88
|
export type Env = {
|
|
78
89
|
readonly [k: string]: string | undefined;
|
|
79
90
|
};
|
|
80
|
-
export type
|
|
91
|
+
export type App = (io: Io) => Promise<number>;
|
|
92
|
+
export type Run = (f: App) => Promise<never>;
|
|
81
93
|
/**
|
|
82
94
|
* Runs a function and exits the process with the returned code
|
|
83
95
|
* Handles errors by exiting with code 1
|
package/io/module.f.js
CHANGED
package/io/module.js
CHANGED
|
@@ -9,11 +9,12 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
9
9
|
import { run } from "./module.f.js";
|
|
10
10
|
import fs from 'node:fs';
|
|
11
11
|
import process from "node:process";
|
|
12
|
+
import { concat } from "../path/module.f.js";
|
|
12
13
|
export const io = {
|
|
13
14
|
console,
|
|
14
15
|
fs,
|
|
15
16
|
process,
|
|
16
|
-
asyncImport: (v) => import(__rewriteRelativeImportExtension(v)),
|
|
17
|
+
asyncImport: (v) => import(__rewriteRelativeImportExtension(`file:///${concat(process.cwd())(v)}`)),
|
|
17
18
|
performance,
|
|
18
19
|
tryCatch: f => {
|
|
19
20
|
try {
|
package/io/virtual.f.js
CHANGED
|
@@ -12,12 +12,16 @@ export const createVirtualIo = (files) => ({
|
|
|
12
12
|
readdir: (_path) => Promise.resolve([]),
|
|
13
13
|
readFile: (_path, _options) => Promise.resolve(''),
|
|
14
14
|
writeFile: (_path, _data, _options) => Promise.resolve(),
|
|
15
|
+
rm: (_path, _options) => Promise.resolve(),
|
|
16
|
+
mkdir: (_path, _options) => Promise.resolve(undefined),
|
|
17
|
+
copyFile: (_src, _dest) => Promise.resolve(),
|
|
15
18
|
}
|
|
16
19
|
},
|
|
17
20
|
process: {
|
|
18
21
|
argv: [],
|
|
19
22
|
env: {},
|
|
20
23
|
exit: n => { throw n; },
|
|
24
|
+
cwd: () => '',
|
|
21
25
|
},
|
|
22
26
|
asyncImport: () => Promise.reject(),
|
|
23
27
|
performance: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"test20": "npm run tsc-emit && npm run n ./dev/test/module.js",
|
|
16
16
|
"test22": "tsc && npm run n -- --experimental-strip-types ./dev/test/module.ts",
|
|
17
17
|
"test": "tsc && npm run n ./dev/test/module.ts",
|
|
18
|
-
"index": "npm run n ./dev/index.ts",
|
|
18
|
+
"index": "npm run n ./dev/index/module.ts",
|
|
19
19
|
"fsc": "npm run n ./fsc/module.ts",
|
|
20
20
|
"update": "npm run index && npm install"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
|
-
"node": ">=
|
|
23
|
+
"node": ">=20"
|
|
24
24
|
},
|
|
25
25
|
"bin": {
|
|
26
26
|
"fsc": "fsc/module.js"
|
package/path/module.f.js
CHANGED
package/dev/index.js
DELETED
|
File without changes
|