File tree Expand file tree Collapse file tree 3 files changed +127
-1
lines changed Expand file tree Collapse file tree 3 files changed +127
-1
lines changed Original file line number Diff line number Diff line change 1+ SELECT * FROM my_table WHERE my_column = ${val}
Original file line number Diff line number Diff line change 1+ {
2+ "type" : " Cell" ,
3+ "start" : 0 ,
4+ "end" : 48 ,
5+ "id" : null ,
6+ "body" : {
7+ "type" : " TemplateLiteral" ,
8+ "start" : 0 ,
9+ "end" : 48 ,
10+ "expressions" : [
11+ {
12+ "type" : " Identifier" ,
13+ "start" : 43 ,
14+ "end" : 46 ,
15+ "name" : " val"
16+ }
17+ ],
18+ "quasis" : [
19+ {
20+ "type" : " TemplateElement" ,
21+ "start" : 0 ,
22+ "end" : 41 ,
23+ "value" : {
24+ "raw" : " SELECT * FROM my_table WHERE my_column = " ,
25+ "cooked" : null
26+ },
27+ "tail" : false
28+ },
29+ {
30+ "type" : " TemplateElement" ,
31+ "start" : 47 ,
32+ "end" : 48 ,
33+ "value" : {
34+ "raw" : " \n " ,
35+ "cooked" : null
36+ },
37+ "tail" : true
38+ }
39+ ]
40+ },
41+ "async" : false ,
42+ "generator" : false ,
43+ "tag" : {
44+ "type" : " CellTag" ,
45+ "start" : 0 ,
46+ "end" : 38 ,
47+ "body" : {
48+ "type" : " MemberExpression" ,
49+ "start" : 0 ,
50+ "end" : 38 ,
51+ "object" : {
52+ "type" : " AwaitExpression" ,
53+ "start" : 1 ,
54+ "end" : 33 ,
55+ "argument" : {
56+ "type" : " CallExpression" ,
57+ "start" : 7 ,
58+ "end" : 33 ,
59+ "callee" : {
60+ "type" : " Identifier" ,
61+ "start" : 7 ,
62+ "end" : 21 ,
63+ "name" : " DatabaseClient"
64+ },
65+ "arguments" : [
66+ {
67+ "type" : " Literal" ,
68+ "start" : 22 ,
69+ "end" : 32 ,
70+ "value" : " database" ,
71+ "raw" : " \" database\" "
72+ }
73+ ],
74+ "optional" : false
75+ }
76+ },
77+ "property" : {
78+ "type" : " Identifier" ,
79+ "start" : 35 ,
80+ "end" : 38 ,
81+ "name" : " sql"
82+ },
83+ "computed" : false ,
84+ "optional" : false
85+ },
86+ "input" : " (await DatabaseClient(\" database\" )).sql" ,
87+ "async" : true ,
88+ "generator" : false ,
89+ "references" : [
90+ {
91+ "type" : " Identifier" ,
92+ "start" : 7 ,
93+ "end" : 21 ,
94+ "name" : " DatabaseClient"
95+ }
96+ ],
97+ "fileAttachments" : [],
98+ "databaseClients" : [
99+ [
100+ " database" ,
101+ [
102+ {
103+ "start" : 22 ,
104+ "end" : 32
105+ }
106+ ]
107+ ]
108+ ],
109+ "secrets" : []
110+ },
111+ "raw" : false ,
112+ "references" : [
113+ {
114+ "type" : " Identifier" ,
115+ "start" : 43 ,
116+ "end" : 46 ,
117+ "name" : " val"
118+ }
119+ ],
120+ "fileAttachments" : [],
121+ "databaseClients" : [],
122+ "secrets" : []
123+ }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import {parseCell, walk} from "@observablehq/parser";
77( async ( ) => {
88 for ( const file of fs . readdirSync ( path . join ( "test" , "input" ) ) ) {
99 it ( `parse ${ file } ` , ( ) => {
10- const extension = path . extname ( file ) ;
10+ const extension = file . substring ( file . indexOf ( "." ) ) ; // path.extname, but taking the first dot
1111 const infile = path . join ( "test" , "input" , file ) ;
1212 const outfile = path . resolve ( path . join ( "test" , "output" ) , `${ file } .json` ) ;
1313
@@ -19,6 +19,8 @@ import {parseCell, walk} from "@observablehq/parser";
1919 tag :
2020 extension === ".sql"
2121 ? "db.sql"
22+ : extension === ".db.sql"
23+ ? `(await DatabaseClient("database")).sql`
2224 : extension === ".html"
2325 ? "htl.html"
2426 : extension === ".tex"
You can’t perform that action at this time.
0 commit comments