11import { ChildProcess , exec , execSync } from 'child_process' ;
22import { existsSync , mkdirSync , readFileSync , renameSync , unlinkSync , writeFileSync } from 'fs' ;
3- import { basename , dirname , join } from 'path' ;
3+ import { basename , dirname , join , relative } from 'path' ;
44import {
55 buildTypeResolver , Artifact , CURRENT_CONTRACT_ARTIFACT_VERSION , findCompiler , hash160 , md5 , path2uri , resolveConstValue , TypeResolver
66} from './internal' ;
@@ -457,6 +457,11 @@ export function handleCompilerOutput(
457457 const artifact = result . toArtifact ( ) ;
458458
459459 writeFileSync ( artifactFile , JSON . stringify ( artifact , ( key , value ) => {
460+
461+ if ( key === 'file' ) {
462+ return relative ( artifactFile , value )
463+ }
464+
460465 //ignore deprecated fields
461466 if ( key == 'sources' || key == 'sourceMap' || key === 'asm' )
462467 return undefined ;
@@ -542,7 +547,7 @@ export function getFullFilePath(relativePath: string, baseDir: string, curFileNa
542547 }
543548
544549 if ( relativePath === 'std' ) {
545- return 'std' ; //
550+ return 'std' ; //
546551 }
547552
548553 return join ( baseDir , relativePath ) ;
@@ -612,7 +617,7 @@ function shortGenericType(genericType: string): string {
612617}
613618
614619/**
615- *
620+ *
616621 * @param astRoot AST root node after main contract compilation
617622 * @param typeResolver a Type Resolver
618623 * @returns All function ABIs defined by the main contract, including constructors
@@ -646,7 +651,7 @@ export function getABIDeclaration(astRoot: unknown, typeResolver: TypeResolver):
646651}
647652
648653/**
649- *
654+ *
650655 * @param astRoot AST root node after main contract compilation
651656 * @param dependencyAsts AST root node after all dependency contract compilation
652657 * @returns all defined structures of the main contract and dependent contracts
@@ -672,7 +677,7 @@ export function getStructDeclaration(astRoot: unknown, dependencyAsts: unknown):
672677
673678
674679/**
675- *
680+ *
676681 * @param astRoot AST root node after main contract compilation
677682 * @param dependencyAsts AST root node after all dependency contract compilation
678683 * @returns all defined Library of the main contract and dependent contracts
@@ -748,7 +753,7 @@ export function getContractDeclaration(astRoot: unknown, dependencyAsts: unknown
748753
749754
750755/**
751- *
756+ *
752757 * @param astRoot AST root node after main contract compilation
753758 * @param dependencyAsts AST root node after all dependency contract compilation
754759 * @returns all defined type aliaes of the main contract and dependent contracts
@@ -772,7 +777,7 @@ export function getAliasDeclaration(astRoot: unknown, dependencyAsts: unknown):
772777
773778
774779/**
775- *
780+ *
776781 * @param astRoot AST root node after main contract compilation
777782 * @param dependencyAsts AST root node after all dependency contract compilation
778783 * @returns all defined static const int literal of the main contract and dependent contracts
@@ -928,7 +933,7 @@ function parserAst(result: CompileResult, ast: any, srcDir: string, sourceFileNa
928933 const allAst = addSourceLocation ( ast , srcDir , sourceFileName ) ;
929934
930935 const sourceUri = path2uri ( sourcePath ) ;
931- result . file = sourceUri ;
936+ result . file = sourcePath ;
932937 result . ast = allAst [ sourceUri ] ;
933938 delete allAst [ sourceUri ] ;
934939 result . dependencyAsts = allAst ;
@@ -977,11 +982,11 @@ function parserAst(result: CompileResult, ast: any, srcDir: string, sourceFileNa
977982
978983/**
979984 * @deprecated use `--hex` when compiling
980- * @param result
981- * @param asmObj
982- * @param settings
983- * @param srcDir
984- * @param sourceFileName
985+ * @param result
986+ * @param asmObj
987+ * @param settings
988+ * @param srcDir
989+ * @param sourceFileName
985990 */
986991function parserASM ( result : CompileResult , asmObj : any , settings : CompilingSettings , srcDir : string , sourceFileName : string ) {
987992
0 commit comments