firefly-compiler 0.4.62 → 0.4.64

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.
@@ -106,7 +106,7 @@ extend self: NodeSystem {
106
106
  environment: Option[Map[String, String]] = None
107
107
  maxBuffer: Int = 16777216
108
108
  killSignal: Int = 9
109
- windowsWhich: Bool = True
109
+ windowsWhere: Bool = True
110
110
  ): ProcessResult
111
111
  target node async """
112
112
  import * as childProcess from 'node:child_process';
@@ -118,10 +118,11 @@ extend self: NodeSystem {
118
118
  ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String
119
119
  );
120
120
  }
121
- if(windowsWhich_ && process.platform === 'win32') {
122
- command_ =
123
- (await internalWhich_$(self_, command_, workingDirectory_, environment_, $task)).value_ ||
124
- command_;
121
+ if(windowsWhere_ && process.platform === 'win32') {
122
+ const cmd = process.env.ComSpec || "cmd.exe";
123
+ command_ = (
124
+ await internalWindowsWhere_$(self_, cmd, command_, workingDirectory_, environment_, $task)
125
+ ).value_ || command_;
125
126
  }
126
127
  const newProcess = childProcess.spawn(command_, arguments_, {
127
128
  cwd: workingDirectory_.value_,
@@ -201,36 +202,22 @@ internalFindCommand(out: String): String {
201
202
  }.else {""}
202
203
  }
203
204
 
204
- internalIsWindows(): Bool
205
- target node sync """
206
- return process.platform === 'win32';
207
- """
208
-
209
- internalWhich(
205
+ internalWindowsWhere(
210
206
  system: NodeSystem
207
+ cmd: String
211
208
  command: String
212
209
  workingDirectory: Option[Path] = None
213
210
  environment: Option[Map[String, String]] = None
214
211
  ): Option[String] {
215
- let out = if(internalIsWindows()) {
216
- system.execute(
217
- "cmd.exe",
218
- ["/c", "where", command],
219
- workingDirectory = workingDirectory
220
- environment = environment
221
- windowsWhich = False
222
- )
223
- } else {
224
- system.execute(
225
- "which",
226
- [command],
227
- workingDirectory = workingDirectory
228
- environment = environment
229
- windowsWhich = False
230
- )
231
- }
212
+ if(!command.all {c => c.isAsciiLetterOrDigit() || c == '_' || c == '-'}) {None} else:
213
+ let out = system.execute(
214
+ cmd,
215
+ ["/c", "where", command],
216
+ workingDirectory = workingDirectory
217
+ environment = environment
218
+ windowsWhere = False
219
+ )
232
220
  out.standardOut.toString().lines().filter {line =>
233
- out.exitCode == 0 &&
234
- (!internalIsWindows() || line.split('\\').last().any {_.contains(".")})
221
+ out.exitCode == 0 && line.split('\\').last().any {_.contains(".")}
235
222
  }.first()
236
223
  }
@@ -136,22 +136,20 @@ return ""
136
136
  }))
137
137
  }
138
138
 
139
- export function internalIsWindows_() {
140
-
141
- return process.platform === 'win32';
142
-
143
- }
144
-
145
- export function internalWhich_(system_, command_, workingDirectory_ = ff_core_Option.None(), environment_ = ff_core_Option.None()) {
146
- const out_ = (ff_core_NodeSystem.internalIsWindows_()
147
- ? ff_core_NodeSystem.NodeSystem_execute(system_, "cmd.exe", ["/c", "where", command_], ff_core_Buffer.new_(0, false), workingDirectory_, environment_, 16777216, 9, false)
148
- : ff_core_NodeSystem.NodeSystem_execute(system_, "which", [command_], ff_core_Buffer.new_(0, false), workingDirectory_, environment_, 16777216, 9, false));
139
+ export function internalWindowsWhere_(system_, cmd_, command_, workingDirectory_ = ff_core_Option.None(), environment_ = ff_core_Option.None()) {
140
+ if((!ff_core_String.String_all(command_, ((c_) => {
141
+ return ((ff_core_Char.Char_isAsciiLetterOrDigit(c_) || (c_ === 95)) || (c_ === 45))
142
+ })))) {
143
+ return ff_core_Option.None()
144
+ } else {
145
+ const out_ = ff_core_NodeSystem.NodeSystem_execute(system_, cmd_, ["/c", "where", command_], ff_core_Buffer.new_(0, false), workingDirectory_, environment_, 16777216, 9, false);
149
146
  return ff_core_List.List_first(ff_core_List.List_filter(ff_core_String.String_lines(ff_core_Buffer.Buffer_toString(out_.standardOut_, "utf8")), ((line_) => {
150
- return ((out_.exitCode_ === 0) && ((!ff_core_NodeSystem.internalIsWindows_()) || ff_core_Option.Option_any(ff_core_List.List_last(ff_core_String.String_split(line_, 92)), ((_w1) => {
147
+ return ((out_.exitCode_ === 0) && ff_core_Option.Option_any(ff_core_List.List_last(ff_core_String.String_split(line_, 92)), ((_w1) => {
151
148
  return ff_core_String.String_contains(_w1, ".")
152
- }))))
149
+ })))
153
150
  })))
154
151
  }
152
+ }
155
153
 
156
154
  export async function internalAssets_$(system_, $task) {
157
155
  return system_.assets_
@@ -183,19 +181,19 @@ return ""
183
181
  }))
184
182
  }
185
183
 
186
- export async function internalIsWindows_$($task) {
187
- throw new Error('Function internalIsWindows is missing on this target in async context.');
188
- }
189
-
190
- export async function internalWhich_$(system_, command_, workingDirectory_ = ff_core_Option.None(), environment_ = ff_core_Option.None(), $task) {
191
- const out_ = (ff_core_NodeSystem.internalIsWindows_()
192
- ? (await ff_core_NodeSystem.NodeSystem_execute$(system_, "cmd.exe", ["/c", "where", command_], ff_core_Buffer.new_(0, false), workingDirectory_, environment_, 16777216, 9, false, $task))
193
- : (await ff_core_NodeSystem.NodeSystem_execute$(system_, "which", [command_], ff_core_Buffer.new_(0, false), workingDirectory_, environment_, 16777216, 9, false, $task)));
184
+ export async function internalWindowsWhere_$(system_, cmd_, command_, workingDirectory_ = ff_core_Option.None(), environment_ = ff_core_Option.None(), $task) {
185
+ if((!ff_core_String.String_all(command_, ((c_) => {
186
+ return ((ff_core_Char.Char_isAsciiLetterOrDigit(c_) || (c_ === 95)) || (c_ === 45))
187
+ })))) {
188
+ return ff_core_Option.None()
189
+ } else {
190
+ const out_ = (await ff_core_NodeSystem.NodeSystem_execute$(system_, cmd_, ["/c", "where", command_], ff_core_Buffer.new_(0, false), workingDirectory_, environment_, 16777216, 9, false, $task));
194
191
  return ff_core_List.List_first(ff_core_List.List_filter(ff_core_String.String_lines(ff_core_Buffer.Buffer_toString(out_.standardOut_, "utf8")), ((line_) => {
195
- return ((out_.exitCode_ === 0) && ((!ff_core_NodeSystem.internalIsWindows_()) || ff_core_Option.Option_any(ff_core_List.List_last(ff_core_String.String_split(line_, 92)), ((_w1) => {
192
+ return ((out_.exitCode_ === 0) && ff_core_Option.Option_any(ff_core_List.List_last(ff_core_String.String_split(line_, 92)), ((_w1) => {
196
193
  return ff_core_String.String_contains(_w1, ".")
197
- }))))
198
194
  })))
195
+ })))
196
+ }
199
197
  }
200
198
 
201
199
  export function NodeSystem_arguments(self_) {
@@ -294,7 +292,7 @@ export function NodeSystem_environment(self_) {
294
292
  throw new Error('Function NodeSystem_environment is missing on this target in sync context.');
295
293
  }
296
294
 
297
- export function NodeSystem_execute(self_, command_, arguments_, standardIn_ = ff_core_Buffer.new_(0), workingDirectory_ = ff_core_Option.None(), environment_ = ff_core_Option.None(), maxBuffer_ = 16777216, killSignal_ = 9, windowsWhich_ = true) {
295
+ export function NodeSystem_execute(self_, command_, arguments_, standardIn_ = ff_core_Buffer.new_(0), workingDirectory_ = ff_core_Option.None(), environment_ = ff_core_Option.None(), maxBuffer_ = 16777216, killSignal_ = 9, windowsWhere_ = true) {
298
296
  throw new Error('Function NodeSystem_execute is missing on this target in sync context.');
299
297
  }
300
298
 
@@ -408,7 +406,7 @@ export async function NodeSystem_environment$(self_, $task) {
408
406
 
409
407
  }
410
408
 
411
- export async function NodeSystem_execute$(self_, command_, arguments_, standardIn_ = ff_core_Buffer.new_(0), workingDirectory_ = ff_core_Option.None(), environment_ = ff_core_Option.None(), maxBuffer_ = 16777216, killSignal_ = 9, windowsWhich_ = true, $task) {
409
+ export async function NodeSystem_execute$(self_, command_, arguments_, standardIn_ = ff_core_Buffer.new_(0), workingDirectory_ = ff_core_Option.None(), environment_ = ff_core_Option.None(), maxBuffer_ = 16777216, killSignal_ = 9, windowsWhere_ = true, $task) {
412
410
 
413
411
  const childProcess = import$3;
414
412
  const environment = environment_.value_ !== void 0 ? {} : process.env;
@@ -419,10 +417,11 @@ export async function NodeSystem_execute$(self_, command_, arguments_, standardI
419
417
  ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String
420
418
  );
421
419
  }
422
- if(windowsWhich_ && process.platform === 'win32') {
423
- command_ =
424
- (await internalWhich_$(self_, command_, workingDirectory_, environment_, $task)).value_ ||
425
- command_;
420
+ if(windowsWhere_ && process.platform === 'win32') {
421
+ const cmd = process.env.ComSpec || "cmd.exe";
422
+ command_ = (
423
+ await internalWindowsWhere_$(self_, cmd, command_, workingDirectory_, environment_, $task)
424
+ ).value_ || command_;
426
425
  }
427
426
  const newProcess = childProcess.spawn(command_, arguments_, {
428
427
  cwd: workingDirectory_.value_,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly compiler",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.4.62",
7
+ "version": "0.4.64",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly language support",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.4.62",
7
+ "version": "0.4.64",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"