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())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self += l + "\n"
|
self += l
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) == 2 {
|
if len(os.Args) == 3 {
|
||||||
errFilename := os.Args[1];
|
errFilename := os.Args[1];
|
||||||
|
srcMapFilename := os.Args[2];
|
||||||
errFile, err1 := os.ReadFile(errFilename);
|
errFile, err1 := os.ReadFile(errFilename);
|
||||||
srcMapFile, err2 := os.ReadFile(".srcmap");
|
srcMapFile, err2 := os.ReadFile(srcMapFilename);
|
||||||
if err1 != nil || err2 != nil {
|
if err1 != nil || err2 != nil {
|
||||||
panic("Couldn't open either the error temp file or the source map");
|
panic("Couldn't open either the error temp file or the source map");
|
||||||
}
|
}
|
||||||
srcMap := srcMapDeserialize(string(srcMapFile[:]))
|
srcMap := srcMapDeserialize(string(srcMapFile[:]))
|
||||||
fmt.Print(buildOutputTransform(string(errFile[:]), srcMap))
|
fmt.Print(buildOutputTransform(string(errFile[:]), srcMap))
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("usage: sourcemapper ERRFILE");
|
fmt.Println("usage: sourcemapper ERRFILE SRCMAP");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,12 +9,13 @@ if [ ! -z "$1" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# build the source map and concatenate the source
|
# build the source map and concatenate the source
|
||||||
|
srcmap=$(mktemp)
|
||||||
for f in *.ts; do
|
for f in *.ts; do
|
||||||
lines=$(wc -l ${f})
|
lines=$(wc -l ${f})
|
||||||
set ${lines}
|
set ${lines}
|
||||||
lines=$1
|
lines=$1
|
||||||
|
|
||||||
echo "${f}\t${lines}" >> .srcmap
|
echo "${f}\t${lines}" >> ${srcmap}
|
||||||
cat ${f} >> ${progname}.ts
|
cat ${f} >> ${progname}.ts
|
||||||
done
|
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}
|
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
|
# translate lines into original source with the source map and output to stdout
|
||||||
../buildtools/sourcemapper ${errorOut}
|
../buildtools/sourcemapper ${errorOut} ${srcmap}
|
||||||
|
|
||||||
# delete the temporary files
|
# delete the temporary files
|
||||||
rm ${errorOut}
|
rm ${errorOut}
|
||||||
rm ${progname}.ts
|
rm ${progname}.ts
|
||||||
rm .srcmap
|
rm ${srcmap}
|
Loading…
Reference in a new issue