MCPcopy Create free account
hub / github.com/bigcommerce/stencil-cli / tryToFix

Method tryToFix

lib/nodeSass/AutoFixer.js:58–85  ·  view source on GitHub ↗
(err, file)

Source from the content-addressed store, hash-verified

56 }
57
58 async tryToFix(err, file) {
59 const problem = this.detectProblem(err);
60 if (problem) {
61 const dirname = path.join(this.themePath, 'assets/scss');
62 let files = [];
63 if (problem === CONDITIONAL_IMPORT) {
64 const fixer = new ConditionaImportFixer(dirname, err.file);
65 files = await fixer.run();
66 } else if (problem === BASE_LEVEL_RULES) {
67 const baseRulesFixer = new BaseRulesFixer(dirname, err.file);
68 files = await baseRulesFixer.run();
69 } else if (problem === POSSIBLE_WRONG_COMMA) {
70 const toFixFile = err.file === 'stdin' ? file : err.file;
71 const commaRemovalFixer = new CommaRemovalFixer(dirname, toFixFile);
72 files = await commaRemovalFixer.run();
73 } else if (problem === UNDEFINED_VARIABLE) {
74 const toFixFile = err.file === 'stdin' ? file : err.file;
75 const fixer = new UndefinedVariableFixer(dirname, toFixFile);
76 files = await fixer.run(err.message);
77 }
78 this.parseChangedFiles(files);
79 } else {
80 const filePath = path.join(this.themePath, 'assets/scss', file + '.scss');
81 console.log("Couldn't determine and autofix the problem. Please fix it manually.".red);
82 console.log('Found trying to compile file:'.red, filePath);
83 throw new Error(err.formatted ? err.formatted : err);
84 }
85 }
86
87 detectProblem(err) {
88 if (err.formatted) {

Callers 1

runMethod · 0.95

Calls 6

detectProblemMethod · 0.95
runMethod · 0.95
runMethod · 0.95
runMethod · 0.95
parseChangedFilesMethod · 0.95
logMethod · 0.80

Tested by

no test coverage detected