@@ -40,6 +40,7 @@ import nextflow.script.formatter.ScriptFormattingVisitor
4040import nextflow.script.parser.v2.ErrorListener
4141import nextflow.script.parser.v2.ErrorSummary
4242import nextflow.script.parser.v2.StandardErrorListener
43+ import nextflow.util.ClassLoaderFactory
4344import nextflow.util.PathUtils
4445import org.codehaus.groovy.control.SourceUnit
4546import org.codehaus.groovy.control.messages.SyntaxErrorMessage
@@ -62,7 +63,7 @@ class CmdLint extends CmdBase {
6263 names = [' -exclude' ],
6364 description = ' File pattern to exclude from error checking (can be specified multiple times)'
6465 )
65- List<String > excludePatterns = [' .git' , ' .lineage' , ' .nf-test ' , ' .nextflow ' , ' work ' , ' nf-test.config' ]
66+ List<String > excludePatterns = [' .git' , ' .lineage' , ' .nextflow ' , ' .nf-test ' , ' nf-test.config' , ' work ' ]
6667
6768 @Parameter (
6869 names = [' -o' , ' -output' ],
@@ -82,6 +83,12 @@ class CmdLint extends CmdBase {
8283 }
8384 }
8485
86+ @Parameter (
87+ names = [' -project-dir' ],
88+ description = ' Path to project directory (default: .)'
89+ )
90+ String projectDir = ' .'
91+
8592 @Parameter (names = [' -format' ], description = ' Format scripts and config files that have no errors' )
8693 boolean formatting
8794
@@ -121,7 +128,11 @@ class CmdLint extends CmdBase {
121128 if ( ! spaces && ! tabs )
122129 spaces = 4
123130
124- scriptParser = new ScriptParser ()
131+ final baseDir = Path . of(projectDir)
132+ final libDir = baseDir. resolve(' lib' )
133+ final classLoader = ClassLoaderFactory . create([ libDir ])
134+
135+ scriptParser = new ScriptParser (baseDir, classLoader)
125136 configParser = new ConfigParser ()
126137 errorListener = outputMode == ' json'
127138 ? new JsonErrorListener ()
0 commit comments