@@ -76,23 +76,28 @@ function deleteRemoteRuleset() {
76
76
77
77
export const handler = async ( argv : Arguments < Options > ) : Promise < void > => {
78
78
// Open the provided API Spec
79
- const { specPath, save, json } = argv ;
79
+ const { specPath, save, json, ruleset } = argv ;
80
80
const specFile = fs . readFileSync ( specPath , "utf8" ) ;
81
81
const spec = YAML . parse ( specFile ) ;
82
82
var specName = path . basename ( specPath , path . extname ( specPath ) ) ;
83
83
84
- // attempt to download the ruleset
85
- let downloadSuccess = true ;
86
- try {
87
- await downloadRuleset ( rulesetUrl , rulesetFilepath ) ;
88
- } catch ( error ) {
89
- // Error downloading the remote ruleset - use the bundled local copy
90
- console. warn ( chalk . yellow . bold ( "Failed to download remote ruleset. Using Local Copy." ) ) ;
91
- console . log ( "Note that lint results may vary from production ruleset." ) ;
92
- rulesetFilename = "./static/.local.spectral.yaml" ;
93
- rulesetFilepath = path . join ( __dirname , ".." , rulesetFilename ) ;
94
- console . log ( rulesetFilepath ) ;
95
- downloadSuccess = false ;
84
+ // attempt to download the ruleset if no local file was provided
85
+ var downloadSuccess ;
86
+ if ( ! ruleset ) {
87
+ downloadSuccess = true ;
88
+ try {
89
+ await downloadRuleset ( rulesetUrl , rulesetFilepath ) ;
90
+ } catch ( error ) {
91
+ // Error downloading the remote ruleset - use the bundled local copy
92
+ console. warn ( chalk . yellow . bold ( "Failed to download remote ruleset. Using Local Copy." ) ) ;
93
+ console . log ( "Note that lint results may vary from production ruleset." ) ;
94
+ rulesetFilename = "./static/.local.spectral.yaml" ;
95
+ rulesetFilepath = path . join ( __dirname , ".." , rulesetFilename ) ;
96
+ console . log ( rulesetFilepath ) ;
97
+ downloadSuccess = false ;
98
+ }
99
+ } else {
100
+ rulesetFilepath = path . join ( __dirname , ".." , ruleset ) ;
96
101
}
97
102
98
103
// Setup Spectral and load ruleset
0 commit comments