purus 0.3.0 → 0.4.1
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/README-ja.md +14 -0
- package/README.md +14 -0
- package/bin/purus.js +9 -5
- package/lib/build-wrapper.js +14 -17
- package/lib/check-wrapper.js +97 -0
- package/lib/create.js +4 -1
- package/lib/purus-compiler.js +1365 -932
- package/lib/run-wrapper.js +12 -15
- package/package.json +4 -4
package/lib/run-wrapper.js
CHANGED
|
@@ -8,32 +8,31 @@ const { compile } = require("./purus-core.js");
|
|
|
8
8
|
|
|
9
9
|
const args = process.argv.slice(3);
|
|
10
10
|
|
|
11
|
-
let
|
|
12
|
-
let directory = null;
|
|
11
|
+
let entry = null;
|
|
13
12
|
let noHeader = false;
|
|
14
13
|
|
|
15
14
|
for (let i = 0; i < args.length; i++) {
|
|
16
15
|
if (args[i] === "--no-header") {
|
|
17
16
|
noHeader = true;
|
|
18
|
-
} else if (args[i] === "--
|
|
19
|
-
|
|
17
|
+
} else if (args[i] === "--entry" || args[i] === "-e") {
|
|
18
|
+
entry = args[++i];
|
|
20
19
|
} else if (!args[i].startsWith("-")) {
|
|
21
|
-
|
|
20
|
+
entry = args[i];
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
if (
|
|
24
|
+
if (entry && fs.existsSync(entry) && fs.statSync(entry).isFile()) {
|
|
26
25
|
// Single file - compile and run
|
|
27
|
-
const source = fs.readFileSync(
|
|
26
|
+
const source = fs.readFileSync(entry, "utf8");
|
|
28
27
|
const js = compile(source, { header: false });
|
|
29
28
|
const m = new (require("module"))();
|
|
30
|
-
m._compile(js,
|
|
29
|
+
m._compile(js, entry);
|
|
31
30
|
} else {
|
|
32
31
|
let entryDir;
|
|
33
32
|
let useHeader;
|
|
34
33
|
|
|
35
|
-
if (
|
|
36
|
-
entryDir = path.resolve(
|
|
34
|
+
if (entry) {
|
|
35
|
+
entryDir = path.resolve(entry);
|
|
37
36
|
useHeader = false;
|
|
38
37
|
} else {
|
|
39
38
|
const result = loadConfig();
|
|
@@ -41,11 +40,9 @@ if (file) {
|
|
|
41
40
|
console.log("Error: no input file specified and no config.purus found");
|
|
42
41
|
console.log("");
|
|
43
42
|
console.log("Usage:");
|
|
44
|
-
console.log(" purus run <file>
|
|
45
|
-
console.log(
|
|
46
|
-
|
|
47
|
-
);
|
|
48
|
-
console.log(" purus run Run using config.purus");
|
|
43
|
+
console.log(" purus run <file|dir> Run a file or directory");
|
|
44
|
+
console.log(" purus run --entry <file|dir> Specify entry");
|
|
45
|
+
console.log(" purus run Run using config.purus");
|
|
49
46
|
process.exit(1);
|
|
50
47
|
}
|
|
51
48
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "purus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "A language that compiles to JavaScript — no Shift key required",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"build:compiler": "moon build --target js",
|
|
27
27
|
"build:copy": "node scripts/build.js",
|
|
28
28
|
"build": "npm run build:compiler && npm run build:copy",
|
|
29
|
-
"
|
|
29
|
+
"sync-version": "node scripts/sync-version.js",
|
|
30
|
+
"prepublishOnly": "npm run sync-version && npm run build"
|
|
30
31
|
},
|
|
31
32
|
"keywords": [
|
|
32
33
|
"compiler",
|
|
@@ -36,8 +37,7 @@
|
|
|
36
37
|
"altjs",
|
|
37
38
|
"lang",
|
|
38
39
|
"purus",
|
|
39
|
-
"noshift"
|
|
40
|
-
"noshift.js"
|
|
40
|
+
"noshift"
|
|
41
41
|
],
|
|
42
42
|
"author": "otoneko1102 (https://github.com/otoneko1102)",
|
|
43
43
|
"license": "Apache-2.0",
|