@quenk/wml 2.11.4 → 2.12.0

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/lib/cli.js CHANGED
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.compileFile = exports.compileDir = void 0;
4
- var path_1 = require("path");
5
- var future_1 = require("@quenk/noni/lib/control/monad/future");
6
- var file_1 = require("@quenk/noni/lib/io/file");
7
- var compile_1 = require("./compile");
4
+ const path_1 = require("path");
5
+ const future_1 = require("@quenk/noni/lib/control/monad/future");
6
+ const file_1 = require("@quenk/noni/lib/io/file");
7
+ const compile_1 = require("./compile");
8
8
  /**
9
9
  * compileDir will compile each wml file found in the specified path.
10
10
  */
11
- var compileDir = function (path, opts) {
12
- return (0, file_1.listFilesRec)(path)
13
- .map(function (list) {
14
- return list
15
- .map(function (p) { return (0, path_1.resolve)(path, p); })
16
- .map(function (p) { return (0, exports.compileFile)(p, opts); });
17
- })
18
- .chain(future_1.parallel);
19
- };
11
+ const compileDir = (path, opts) => (0, file_1.listFilesRec)(path)
12
+ .map(list => list
13
+ .map(p => (0, path_1.resolve)(path, p))
14
+ .map(p => (0, exports.compileFile)(p, opts)))
15
+ .chain(future_1.parallel);
20
16
  exports.compileDir = compileDir;
21
17
  /**
22
18
  * compileFile will compile a single wml file.
@@ -24,25 +20,24 @@ exports.compileDir = compileDir;
24
20
  * If that file does not have the specified inputExtension, it will be
25
21
  * ignored.
26
22
  */
27
- var compileFile = function (path, opts) {
28
- if ((0, path_1.extname)(path) !== ".".concat(opts.inputExtension)) {
23
+ const compileFile = (path, opts) => (0, future_1.doFuture)(function* () {
24
+ if ((0, path_1.extname)(path) !== `.${opts.inputExtension}`) {
29
25
  return (0, future_1.pure)(undefined);
30
26
  }
31
27
  else {
32
- var p_1 = "".concat(getFileName(path), ".").concat(opts.outputExtension);
33
- return (0, file_1.readTextFile)(path)
34
- .chain(function (buf) {
35
- var eitherTs = (0, compile_1.compile)(buf, opts);
36
- if (eitherTs.isLeft())
37
- return (0, future_1.raise)(eitherTs.takeLeft());
38
- else
39
- return (0, future_1.pure)(eitherTs.takeRight());
40
- })
41
- .chain(function (txt) { return (0, file_1.writeTextFile)(p_1, txt); });
28
+ let p = `${getFileName(path)}.${opts.outputExtension}`;
29
+ let buf = yield (0, file_1.readTextFile)(path);
30
+ let eitherTs = (0, compile_1.compile)(buf, opts);
31
+ if (eitherTs.isLeft()) {
32
+ let msg = eitherTs.takeLeft().message;
33
+ return (0, future_1.raise)(new Error(`Error occurred while compiling "${path}":\n ${msg}`));
34
+ }
35
+ else {
36
+ yield (0, file_1.writeTextFile)(p, eitherTs.takeRight());
37
+ }
38
+ return future_1.voidPure;
42
39
  }
43
- };
40
+ });
44
41
  exports.compileFile = compileFile;
45
- var getFileName = function (file) {
46
- return "".concat((0, path_1.dirname)(file), "/").concat((0, path_1.basename)(file, (0, path_1.extname)(file)));
47
- };
42
+ const getFileName = (file) => `${(0, path_1.dirname)(file)}/${(0, path_1.basename)(file, (0, path_1.extname)(file))}`;
48
43
  //# sourceMappingURL=cli.js.map
package/lib/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["cli.ts"],"names":[],"mappings":";;;AAAA,6BAA2D;AAE3D,+DAK8C;AAC9C,gDAIiC;AAEjC,qCAA6C;AAuC7C;;GAEG;AACI,IAAM,UAAU,GAAG,UAAC,IAAY,EAAE,IAAgB;IACrD,OAAA,IAAA,mBAAY,EAAC,IAAI,CAAC;SACb,GAAG,CAAC,UAAA,IAAI;QACL,OAAA,IAAI;aACC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,IAAA,cAAO,EAAC,IAAI,EAAE,CAAC,CAAC,EAAhB,CAAgB,CAAC;aAC1B,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,IAAA,mBAAW,EAAC,CAAC,EAAE,IAAI,CAAC,EAApB,CAAoB,CA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Q,CAAC;KAEjB;AACL,CAAC,CAAC,CAAC;AA9BU,QAAA,WAAW,eA8BrB;AAEH,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,EAAE,CACjC,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,IAAI,IAAA,eAAQ,EAAC,IAAI,EAAE,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC,EAAE,CAAC"}
package/lib/cli.ts CHANGED
@@ -4,7 +4,9 @@ import {
4
4
  Future,
5
5
  pure,
6
6
  raise,
7
- parallel
7
+ parallel,
8
+ doFuture,
9
+ voidPure
8
10
  } from '@quenk/noni/lib/control/monad/future';
9
11
  import {
10
12
  listFilesRec,
@@ -68,8 +70,8 @@ export const compileDir = (path: string, opts: CLIOptions) =>
68
70
  * If that file does not have the specified inputExtension, it will be
69
71
  * ignored.
70
72
  */
71
- export const compileFile = (path: string, opts: CLIOptions)
72
- : Future<void> => {
73
+ export const compileFile = (path: string, opts: CLIOptions) : Future<void> =>
74
+ doFuture(function*() {
73
75
 
74
76
  if (extname(path) !== `.${opts.inputExtension}`) {
75
77
 
@@ -79,21 +81,26 @@ export const compileFile = (path: string, opts: CLIOptions)
79
81
 
80
82
  let p = `${getFileName(path)}.${opts.outputExtension}`;
81
83
 
82
- return readTextFile(path)
83
- .chain(buf => {
84
+ let buf = yield readTextFile(path);
84
85
 
85
- let eitherTs = compile(buf, opts);
86
+ let eitherTs = compile(buf, opts);
86
87
 
87
- if (eitherTs.isLeft())
88
- return raise<string>(eitherTs.takeLeft());
89
- else
90
- return pure(eitherTs.takeRight());
88
+ if(eitherTs.isLeft()) {
91
89
 
92
- })
93
- .chain(txt => writeTextFile(p, txt));
90
+ let msg = eitherTs.takeLeft().message;
91
+
92
+ return raise(new Error(
93
+ `Error occurred while compiling "${path}":\n ${msg}`));
94
+
95
+ } else {
96
+
97
+ yield writeTextFile(p, eitherTs.takeRight());
94
98
  }
95
99
 
96
- }
100
+ return voidPure;
101
+
102
+ }
103
+ });
97
104
 
98
105
  const getFileName = (file: string) =>
99
106
  `${dirname(file)}/${basename(file, extname(file))}`;
@@ -244,15 +244,7 @@ export declare const attributeName2TS: (_: CodeGenerator, n: ast.Attribute) => s
244
244
  /**
245
245
  * attrs2String
246
246
  */
247
- export declare const attrs2String: (attrs: {
248
- [key: string]: string | string[];
249
- }) => string;
250
- /**
251
- * groupAttrs
252
- */
253
- export declare const groupAttrs: (ctx: CodeGenerator, attrs: ast.Attribute[]) => {
254
- [key: string]: string | string[];
255
- };
247
+ export declare const attrs2String: (ctx: CodeGenerator, attrs: ast.Attribute[]) => string;
256
248
  /**
257
249
  * interpolation2TS
258
250
  */