bare-script 2.2.4 → 2.2.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.
Files changed (2) hide show
  1. package/lib/bare.js +16 -3
  2. package/package.json +1 -1
package/lib/bare.js CHANGED
@@ -20,6 +20,7 @@ options:
20
20
  -h, --help show this help message and exit
21
21
  -c, --code CODE execute the BareScript code
22
22
  -d, --debug enable debug mode
23
+ -s, --static perform static analysis
23
24
  -v, --var VAR EXPR set a global variable to an expression value`;
24
25
 
25
26
 
@@ -86,7 +87,7 @@ export async function main(options) {
86
87
  currentFile = file;
87
88
 
88
89
  // Run the bare-script linter?
89
- if (args.debug) {
90
+ if (args.static || args.debug) {
90
91
  const warnings = lintScript(script);
91
92
  const warningPrefix = `BareScript: Static analysis...`;
92
93
  if (warnings.length === 0) {
@@ -96,6 +97,14 @@ export async function main(options) {
96
97
  for (const warning of warnings) {
97
98
  options.logFn(`BareScript: ${warning}`);
98
99
  }
100
+ if (args.static) {
101
+ throw Error('Static analysis failed');
102
+ }
103
+ }
104
+
105
+ // Skip code execution if linter requested
106
+ if (args.static) {
107
+ continue;
99
108
  }
100
109
  }
101
110
 
@@ -125,8 +134,10 @@ export async function main(options) {
125
134
  }
126
135
  }
127
136
  } catch ({message}) {
128
- const fileStr = (currentFile !== null ? `${currentFile}:\n` : '');
129
- options.logFn(`${fileStr}${message}`);
137
+ if (currentFile !== null) {
138
+ options.logFn(`${currentFile}:`);
139
+ }
140
+ options.logFn(message);
130
141
  statusCode = 1;
131
142
  }
132
143
 
@@ -161,6 +172,8 @@ export function parseArgs(argv) {
161
172
  args.debug = true;
162
173
  } else if (arg === '-h' || arg === '--help') {
163
174
  args.help = true;
175
+ } else if (arg === '-s' || arg === '--static') {
176
+ args.static = true;
164
177
  } else if (arg === '-v' || arg === '--var') {
165
178
  if (iArg + 2 >= argv.length) {
166
179
  throw new Error(`Missing values for ${arg}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "bare-script",
4
- "version": "2.2.4",
4
+ "version": "2.2.5",
5
5
  "description": "BareScript; a lightweight scripting and expression language",
6
6
  "keywords": [
7
7
  "expression",