@makano/rew 1.2.44 → 1.2.46

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,6 +48,11 @@ yargs(hideBin(process.argv))
48
48
  alias: 'w',
49
49
  describe: 'Watch the file for changes',
50
50
  type: 'boolean',
51
+ })
52
+ .option('compile', {
53
+ alias: 'c',
54
+ describe: 'Compile and output the javascript',
55
+ type: 'boolean',
51
56
  });
52
57
  },
53
58
  (argv) => {
@@ -56,7 +61,7 @@ yargs(hideBin(process.argv))
56
61
  log('File not found:'.red.bold, argv.file, ':end');
57
62
  return;
58
63
  }
59
- utils.runFileWithArgv(filePath, { watch: argv.watch });
64
+ utils.runFileWithArgv(filePath, { onlyCompile: argv.compile, watch: argv.watch });
60
65
  },
61
66
  )
62
67
  .command(
@@ -1,8 +1,8 @@
1
1
  // run.js
2
2
  const { run } = require('../main');
3
3
 
4
- function exec(filePath, argv) {
5
- return run(filePath, { argv })?.context?.module?.imports || [];
4
+ function exec(filePath, argv, options = {}) {
5
+ return run(filePath, { argv, ...options })?.context?.module?.imports || [];
6
6
  }
7
7
 
8
8
  module.exports = { execRewFile: exec };
@@ -35,7 +35,7 @@ module.exports = {
35
35
 
36
36
  const runIt = () => {
37
37
  if (options.watch) console.clear();
38
- const imports = execRewFile(filePath, [filePath, ...(argv || [])]);
38
+ const imports = execRewFile(filePath, [filePath, ...(argv || [])], { onlyCompile: options?.onlyCompile });
39
39
  if (options.watch) {
40
40
  imports.forEach((file) => {
41
41
  watchIt(file);
@@ -145,6 +145,15 @@ function compileRewStuff(content, options) {
145
145
  continue;
146
146
  }
147
147
 
148
+
149
+ if (token.type === 'IDENTIFIER' && token.value === 'let') {
150
+ result += '`'
151
+ hooks.push({
152
+ index: fnextToken(i, tokens, 'OTHER', ';').ti,
153
+ value: `\``,
154
+ });
155
+ }
156
+
148
157
  if (token.type === 'IDENTIFIER' && token.value === 'import') {
149
158
  // console.log(nextToken.type);
150
159
  let ind = i + n + 2;
@@ -254,13 +263,20 @@ const cpl = (module.exports.compile = function (file, options = {}) {
254
263
 
255
264
  module.exports.compileFile = function (filepath, options = {}) {
256
265
  const f = getFile(filepath);
266
+ let qrew = false;
257
267
 
258
268
  if(options.qrew || path.extname(filepath) == '.qrew') {
269
+ qrew = true
259
270
  f.content = from_qrew(readFileSync(f.path), options.package || findAppInfo(filepath)?.config.manifest.package || path.basename(filepath).split('.').slice(0, -1).join('.')).toString();
260
- }
271
+ }
261
272
 
262
273
  let compiled_code = cpl(f, { ...options });
263
274
 
275
+ if(options.onlyCompile && !qrew){
276
+ console.log(compiled_code);
277
+ process.exit();
278
+ }
279
+
264
280
  return {
265
281
  compiled_code,
266
282
  file: f,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.44",
3
+ "version": "1.2.46",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {