diff --git a/CHANGELOG.md b/CHANGELOG.md index e6792ed4..51ae795e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Solhint changed how the exit codes are implemented: #### Solhint QUIET mode QUIET mode (-c quiet) option now works with the warnings and may exit with 1 if there are more than defined by user +Thanks to [@juanpcapurro](https://github.com/juanpcapurro) for providing the code

## [4.5.4] - 2024-04-10 diff --git a/e2e/test.js b/e2e/test.js index abef3aec..bd04fe24 100644 --- a/e2e/test.js +++ b/e2e/test.js @@ -84,8 +84,14 @@ describe('e2e', function () { expect(stdout.trim()).to.equal('') }) - it('should show warning when using --init', function () { + it.only('should show warning when using --init', function () { + shell.exec(`pwd`) + shell.exec(`ls`) + const { code, stdout } = shell.exec(`${NODE}solhint --init`) + + console.log("code: ", code) + console.log("stdout: ", stdout) expect(code).to.equal(EXIT_CODES.BAD_OPTIONS) expect(stdout.trim()).to.equal('Configuration file already exists') @@ -96,14 +102,12 @@ describe('e2e', function () { const PATH = '03-no-empty-blocks' const { PREFIX, SUFFIX } = prepareContext(PATH) - describe('No contracts to lint', function () { - it('should fail with appropiate message', function () { - const { code, stderr } = shell.exec(`${NODE}solhint Foo.sol ${SUFFIX}`) - + it('No contracts to lint should fail with appropiate message', function () { + const { code, stderr } = shell.exec(`${NODE}solhint Foo1.sol ${SUFFIX}`) + expect(code).to.equal(EXIT_CODES.BAD_OPTIONS) expect(stderr).to.include('No files to lint!') }) - }) it('should end with REPORTED_ERRORS = 1 because report contains errors', function () { const { code, stdout } = shell.exec(`${NODE}solhint ${PREFIX}Foo.sol ${SUFFIX}`) @@ -211,10 +215,16 @@ describe('e2e', function () { expect(stdout.trim()).to.contain('Code contains empty blocks') }) - it(`should raise error for wrongFunctionDefinitionName() only`, () => { + it.only(`should raise error for wrongFunctionDefinitionName() only`, () => { + shell.exec(`pwd`) + shell.exec(`ls`) + console.log('command :>> ', `${NODE}solhint ${PREFIX}test/FooTest.sol ${SUFFIX2}`) const SUFFIX2 = `-c ${PREFIX}test/.solhint.json --disc` const { code, stdout } = shell.exec(`${NODE}solhint ${PREFIX}test/FooTest.sol ${SUFFIX2}`) + console.log("code: ", code) + console.log("stdout: ", stdout) + expect(code).to.equal(EXIT_CODES.OK) expect(stdout.trim()).to.contain( 'Function wrongFunctionDefinitionName() must match Foundry test naming convention ' diff --git a/solhint.js b/solhint.js index 9eb0b95f..5e7da85f 100755 --- a/solhint.js +++ b/solhint.js @@ -215,6 +215,8 @@ function writeSampleConfigFile() { "extends": "solhint:default" } ` + console.log('configPath :>> ', configPath); + if (!fs.existsSync(configPath)) { fs.writeFileSync(configPath, sampleConfig)