nomen-lang 0.0.3 → 0.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.
Files changed (2) hide show
  1. package/dist/index.mjs +21 -4
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -21466,11 +21466,9 @@ const options = yargs(hideBin(process.argv)).usage("Usage: nomen --in [file/fold
21466
21466
  }).option("audit-runtime", {
21467
21467
  describe: "Path to audit_runtime.c, linked in when --audit is set",
21468
21468
  type: "string"
21469
- }).help(true).check((argv) => {
21470
- if (!argv._.length && !argv.in) throw new Error("Missing required argument: in");
21471
- return true;
21472
- }).parseSync();
21469
+ }).help(true).parseSync();
21473
21470
  try {
21471
+ options.in = options.in ?? resolve_input();
21474
21472
  if (!options.in) process.exit(0);
21475
21473
  if (fs.existsSync(options.in)) {
21476
21474
  let config = {
@@ -21495,6 +21493,25 @@ try {
21495
21493
  } catch (err) {
21496
21494
  console.log("UH", err);
21497
21495
  }
21496
+ function resolve_input() {
21497
+ const cwd = process.cwd();
21498
+ const config_path = path.join(cwd, "package.jsonc");
21499
+ if (fs.existsSync(config_path)) try {
21500
+ const json = fs.readFileSync(config_path, "utf8").replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
21501
+ const parsed = JSON.parse(json);
21502
+ if (parsed.entry) return path.resolve(cwd, parsed.entry);
21503
+ } catch {}
21504
+ let nm_files = [];
21505
+ try {
21506
+ nm_files = fs.readdirSync(cwd).filter((f) => f.endsWith(".nm"));
21507
+ } catch {}
21508
+ if (nm_files.length === 1) return path.resolve(cwd, nm_files[0]);
21509
+ if (nm_files.length > 1) {
21510
+ console.log(`Found ${nm_files.length} .nm files in ${cwd}. Specify which to run with --in:\n ` + nm_files.join("\n "));
21511
+ return;
21512
+ }
21513
+ console.log("Nothing to compile. Pass --in <file/folder>, or run inside a folder with a package.jsonc or a .nm file.");
21514
+ }
21498
21515
  function resolve_lib(file_path) {
21499
21516
  let dir = path.dirname(path.resolve(file_path));
21500
21517
  for (let i = 0; i < 20; i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nomen-lang",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "The CLI for the Nomen programming language.",
5
5
  "keywords": [],
6
6
  "license": "ISC",