use temporary file for srcmap instead of on-disk file
This commit is contained in:
parent
14f1abffa9
commit
c80313085e
3 changed files with 9 additions and 7 deletions
Binary file not shown.
|
@ -50,23 +50,24 @@ func buildOutputTransform(buildOutput string, srcMap map[string]LineRange) strin
|
|||
panic(err.Error())
|
||||
}
|
||||
} else {
|
||||
self += l + "\n"
|
||||
self += l
|
||||
}
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) == 2 {
|
||||
if len(os.Args) == 3 {
|
||||
errFilename := os.Args[1];
|
||||
srcMapFilename := os.Args[2];
|
||||
errFile, err1 := os.ReadFile(errFilename);
|
||||
srcMapFile, err2 := os.ReadFile(".srcmap");
|
||||
srcMapFile, err2 := os.ReadFile(srcMapFilename);
|
||||
if err1 != nil || err2 != nil {
|
||||
panic("Couldn't open either the error temp file or the source map");
|
||||
}
|
||||
srcMap := srcMapDeserialize(string(srcMapFile[:]))
|
||||
fmt.Print(buildOutputTransform(string(errFile[:]), srcMap))
|
||||
} else {
|
||||
fmt.Println("usage: sourcemapper ERRFILE");
|
||||
fmt.Println("usage: sourcemapper ERRFILE SRCMAP");
|
||||
}
|
||||
}
|
|
@ -9,12 +9,13 @@ if [ ! -z "$1" ]; then
|
|||
fi
|
||||
|
||||
# build the source map and concatenate the source
|
||||
srcmap=$(mktemp)
|
||||
for f in *.ts; do
|
||||
lines=$(wc -l ${f})
|
||||
set ${lines}
|
||||
lines=$1
|
||||
|
||||
echo "${f}\t${lines}" >> .srcmap
|
||||
echo "${f}\t${lines}" >> ${srcmap}
|
||||
cat ${f} >> ${progname}.ts
|
||||
done
|
||||
|
||||
|
@ -25,9 +26,9 @@ errorOut=$(mktemp)
|
|||
tsc --strict --target ES2015 --outFile ../static/${progname}.js ${progname}.ts | sed -e s/\(/:/ -e s/,/:/ -e s/\):// | nobs >> ${errorOut}
|
||||
|
||||
# translate lines into original source with the source map and output to stdout
|
||||
../buildtools/sourcemapper ${errorOut}
|
||||
../buildtools/sourcemapper ${errorOut} ${srcmap}
|
||||
|
||||
# delete the temporary files
|
||||
rm ${errorOut}
|
||||
rm ${progname}.ts
|
||||
rm .srcmap
|
||||
rm ${srcmap}
|
Loading…
Reference in a new issue