@@ -8,30 +8,25 @@ async function copySrc(packageName) {
8
8
await cp ( src , 'src' , { recursive : true } )
9
9
}
10
10
11
- function test ( name , lang , code ) {
12
- registerDynamicLanguage ( { [ name ] : lang } )
13
- const tree = parse ( name , code )
14
- const root = tree . root ( )
15
- const node = root . find ( '$NAME = "toml"' )
16
- console . log ( node . kind ( ) )
11
+ function test ( setupConfig ) {
12
+ const { name, languageRegistration, testRunner } = setupConfig
13
+ registerDynamicLanguage ( { [ name ] : languageRegistration } )
14
+ testRunner ( ( code ) => parse ( name , code ) )
17
15
}
18
16
19
17
/** Setup ast-grep/lang package's pre-release and
20
18
* @param {Object } setupConfig
21
- * @param {string } setupConfig.packageName
22
19
* @param {string } setupConfig.name
23
- * @param {Object } setupConfig.testConfig
24
- * @param {Object } setupConfig.testConfig.languageRegistration
25
- * @param {string } setupConfig.testConfig.code
20
+ * @param {string } setupConfig.packageName
21
+ * @param {Function } setupConfig.testRunner
26
22
* @returns {void }
27
23
*/
28
24
function setup ( setupConfig ) {
29
25
const arg = process . argv [ 2 ]
30
26
if ( arg === 'copy' ) {
31
27
copySrc ( setupConfig . packageName )
32
28
} else if ( arg === 'test' ) {
33
- const testConfig = setupConfig . testConfig
34
- test ( setupConfig . name , testConfig . languageRegistration , testConfig . code )
29
+ test ( setupConfig )
35
30
}
36
31
}
37
32
0 commit comments