Browse Source

Compiler random folder support and solium checks

Juan Blanco 1 year ago
parent
commit
6b4f44e463
4 changed files with 19 additions and 8 deletions
  1. 3 7
      package.json
  2. 11 0
      src/compiler.ts
  3. 4 0
      src/linter/solium.ts
  4. 1 1
      tslint.json

+ 3 - 7
package.json

@@ -8,7 +8,7 @@
     "compiler",
     "solhint"
   ],
-  "version": "0.0.49",
+  "version": "0.0.50",
   "publisher": "JuanBlanco",
   "engines": {
     "vscode": "^1.28.0"
@@ -55,11 +55,11 @@
     "fs-extra": "^4.0.3",
     "nethereum-codegen": "^1.0.6",
     "read-yaml": "^1.1.0",
-    "solc": "^0.5.0",
+    "solc": "^0.5.2",
     "solhint": "^1.4.0",
     "solium": "^1.1.8",
     "solparse": "^2.2.5",
-    "truffle-artifactor": "^2.1.4",
+    "truffle-artifactor": "^3.0.7",
     "vscode-languageclient": "^5.1.1",
     "vscode-languageserver": "^5.1.0",
     "solidity-parser-antlr": "^0.3.2",
@@ -123,10 +123,6 @@
           "default": {
             "imports-on-top": 0,
             "variable-declarations": 0,
-            "indentation": [
-              "error",
-              4
-            ],
             "quotes": [
               "error",
               "double"

+ 11 - 0
src/compiler.ts

@@ -91,6 +91,15 @@ function processCompilationOuput(outputString: any, outputChannel: vscode.Output
     }
 }
 
+function ensureDirectoryExistence(filePath) {
+    const dirname = path.dirname(filePath);
+    if (fs.existsSync(dirname)) {
+      return true;
+    }
+    ensureDirectoryExistence(dirname);
+    fs.mkdirSync(dirname);
+  }
+
 function writeCompilationOutputToBuildDirectory(output: any, buildDir: string, sourceDir: string,
                                                     excludePath?: string, singleContractFilePath?: string) {
     const binPath = path.join(vscode.workspace.rootPath, buildDir);
@@ -103,10 +112,12 @@ function writeCompilationOutputToBuildDirectory(output: any, buildDir: string, s
         const relativePath = path.relative(vscode.workspace.rootPath, singleContractFilePath);
         const dirName = path.dirname(path.join(binPath, relativePath));
         const outputCompilationPath = path.join(dirName, path.basename(singleContractFilePath, '.sol') + '-sol-output' + '.json');
+        ensureDirectoryExistence(outputCompilationPath);
         fs.writeFileSync(outputCompilationPath, JSON.stringify(output, null, 4));
     } else {
         const dirName = binPath;
         const outputCompilationPath = path.join(dirName, 'compile-all-output' + '.json');
+        ensureDirectoryExistence(outputCompilationPath);
         if (fs.existsSync(outputCompilationPath)) {
             fs.unlinkSync(outputCompilationPath);
         }

+ 4 - 0
src/linter/solium.ts

@@ -29,6 +29,10 @@ export default class SoliumService implements Linter {
             this.soliumRules = soliumRules;
         }
 
+        if (typeof this.soliumRules['indentation'] === 'undefined' ||  this.soliumRules['indentation'] === null) {
+            this.soliumRules['indentation'] = 'false';
+        }
+
         if (process.platform === 'win32') {
             if (typeof  this.soliumRules['linebreak-style'] === 'undefined' ||  this.soliumRules['linebreak-style'] === null) {
                 this.soliumRules['linebreak-style'] = 'off';

+ 1 - 1
tslint.json

@@ -34,7 +34,7 @@
     "no-eval": true,
     "no-inferrable-types": true,
     "no-shadowed-variable": true,
-    "no-string-literal": true,
+    "no-string-literal": false,
     "no-switch-case-fall-through": true,
     "no-trailing-whitespace": true,
     "no-unused-expression": true,