You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/apps-engine/scripts/deno-cache.js
+30-4Lines changed: 30 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,30 @@ const fs = require('fs');
3
3
constpath=require('path');
4
4
5
5
constSHELL_ERR_CMD_NOT_FOUND=127;
6
+
const{CI}=process.env;
6
7
7
8
/**
8
9
* Matches 'deno 2.3.1' or 'Deno 2.7.11-alpha3.24' or even 'some deno and-anything in between 1.43.5' (as long as everything is in the same line)
9
10
* and extracts the correct version string from those ('2.3.1', '2.7.11' and '1.43.5' respectively).
10
11
*
11
12
* Doesn't match 'denoing 2.3.1' or 'deno2.3.1' or 'mydeno 2.7.11alpha3.24' or 'deno\n1.43.5'
13
+
*
14
+
* The expression gets a bit complicated because the word boundary assertion (\b) identifies the dash (-) as a valid word boundary,
15
+
* but that is not the case for use, as we don't want to match "make-deno" for instance. So, for correctness, we use a negative lookbehind
16
+
* assertion ("(?<!)") BEFORE words to make sure our match is not preceded by a word character (\w), a dash (-) or a dot (.), e.g. it won't
17
+
* match "mydeno", "my-deno", "my.deno", etc. The negative lookbehind also allows us to match "deno" in the start of the input, something that
18
+
* simply using the expression itself wouldn't match. In most other cases, these would be replaced by simply "\b"
19
+
*
20
+
* The exact expression tries find the first line to match a sequence as follows:
21
+
* - A character "D" or "d" that is not preceded by a word character, dash or dot (negative lookbehind)
22
+
* - Followed by the literal sequence "eno"
23
+
* - Followed by any character that is not a word character, dash or dot
24
+
* - Followed by a sequence of zero or more occurrences of any character (non multi line)
25
+
* - Followed by a sequence of one or more numbers, then a dot, then one or more numbers, then a dot, then one or more numbers ("version" capture group)
26
+
* that is NOT preceded by a word character, a dash, or dot (negative lookbehind)
27
+
* - Followed by a word boundary (here we're less picky with the "\b" assertion, as we're out of the capture group)
thrownewError(`Incorrect Deno version. Required '${denoToolVersion}', found '${installedVersion}'`);
48
+
constmessage=`Incorrect Deno version. Required '${denoToolVersion}', found '${installedVersion}'.${!CI&&" The server will likely work, but it may cause your deno.lock to change - do not to commit it. Make sure your Deno version matches the required one so you don't see this message again."}`;
49
+
50
+
if(CI){
51
+
thrownewError(message);
52
+
}
53
+
54
+
// We don't need to fail if a dev environment doesn't have a matching Deno version, just the warning is enough
0 commit comments