whet 0.0.23 → 0.0.24

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.
@@ -119,7 +119,7 @@ class SourceData extends Register.inherits() {
119
119
  return new Promise(function (res, rej) {
120
120
  Fs.readFile(path, function (err, buffer) {
121
121
  if (err != null) {
122
- Log.log(50, ...["File does not exist.", {"id": id, "path": path}]);
122
+ Log.log(50, ...["File does not exist.", {"id": id, "path": path, "error": err}]);
123
123
  rej(err);
124
124
  } else {
125
125
  var source = SourceData.fromBytes(id, buffer);
@@ -17,6 +17,7 @@ export declare class IdUtils {
17
17
  static getDir(id: string): string
18
18
  static setDir(id: string, dir: string): string
19
19
  static fromCwdPath(s: string, root: string): string
20
+ static normalize(str: string): string
20
21
  }
21
22
 
22
23
  export declare class RootDir {
@@ -110,6 +110,13 @@ class IdUtils {
110
110
  var rootStr = Path.posix.resolve(root);
111
111
  return Path.posix.relative(rootStr, absPath1);
112
112
  }
113
+ static normalize(str) {
114
+ if (str.length > 0) {
115
+ str = Path.posix.normalize(str);
116
+ str = StringTools.replace(str, "\\", "/");
117
+ };
118
+ return str;
119
+ }
113
120
  static get __name__() {
114
121
  return "whet.IdUtils"
115
122
  }
package/bin/whet/Whet.js CHANGED
@@ -12,7 +12,7 @@ const $global = Register.$global
12
12
  export const Whet_Fields_ = Register.global("$hxClasses")["whet._Whet.Whet_Fields_"] =
13
13
  class Whet_Fields_ {
14
14
  static main() {
15
- Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.23", "-v, --version").allowUnknownOption(true).showSuggestionAfterError(true).option("-p, --project <file>", "project to run", "Project.mjs").option("-l, --log-level <level>", "log level, a string/number", "info").option("--no-pretty", "disable pretty logging").exitOverride();
15
+ Whet_Fields_.program.enablePositionalOptions().passThroughOptions().description("Project tooling.").usage("[options] [command] [+ [command]...]").version("0.0.24", "-v, --version").allowUnknownOption(true).showSuggestionAfterError(true).option("-p, --project <file>", "project to run", "Project.mjs").option("-l, --log-level <level>", "log level, a string/number", "info").option("--no-pretty", "disable pretty logging").exitOverride();
16
16
  try {
17
17
  Whet_Fields_.program.parse();
18
18
  }catch (_g) {
@@ -10,6 +10,7 @@ export declare class RemoteFile extends Stone<RemoteFileConfig> {
10
10
  constructor(config: RemoteFileConfig)
11
11
  protected initConfig(): void
12
12
  protected generate(hash: SourceHash): Promise<SourceData[]>
13
+ protected get(url: string, res: ((arg0: SourceData[]) => void), rej: ((reason: any) => void)): void
13
14
  list(): Promise<string[]>
14
15
  generateHash(): Promise<SourceHash>
15
16
  protected getId(): string
@@ -25,19 +25,27 @@ class RemoteFile extends Register.inherits(Stone) {
25
25
  var _gthis = this;
26
26
  Log.log(30, ...["Downloading file.", {"url": this.config.url}]);
27
27
  return new Promise(function (res, rej) {
28
- Https.get(_gthis.config.url, function (response) {
29
- if (response.statusCode < 200 || response.statusCode >= 300) {
30
- response.resume();
31
- throw new Error("Error downloading file. " + response.statusCode + " – " + response.statusMessage);
32
- };
33
- var bufs = [];
34
- response.on("data", function (d) {
35
- return bufs.push(d);
36
- });
37
- response.on("end", function () {
38
- var data = Buffer.concat(bufs);
39
- res([SourceData.fromBytes(_gthis.getId(), data)]);
40
- });
28
+ _gthis.get(_gthis.config.url, res, rej);
29
+ });
30
+ }
31
+ get(url, res, rej) {
32
+ var _gthis = this;
33
+ Https.get(url, function (response) {
34
+ if (response.statusCode == 301 || response.statusCode == 302) {
35
+ _gthis.get(response.headers["location"], res, rej);
36
+ return;
37
+ };
38
+ if (response.statusCode < 200 || response.statusCode >= 300) {
39
+ response.resume();
40
+ throw new Error("Error downloading file. " + response.statusCode + " – " + response.statusMessage);
41
+ };
42
+ var bufs = [];
43
+ response.on("data", function (d) {
44
+ return bufs.push(d);
45
+ });
46
+ response.on("end", function () {
47
+ var data = Buffer.concat(bufs);
48
+ res([SourceData.fromBytes(_gthis.getId(), data)]);
41
49
  });
42
50
  });
43
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whet",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "NodeJS based assets management and project tooling library.",
5
5
  "scripts": {
6
6
  "devinit": "npx dts2hx commander pino-pretty --modular --noLibWrap",