mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-23 14:31:55 +03:00
wrap typescript in overrides
This commit is contained in:
parent
48c92cfd39
commit
c991447b05
@ -109,17 +109,38 @@ in
|
||||
electronAppDir = "src";
|
||||
|
||||
preBuild = {outputs, ...}: ''
|
||||
# link dependencies of subpackage
|
||||
ln -s \
|
||||
${outputs.subPackages.edex-ui-subpackage.packages.edex-ui-subpackage}/lib/node_modules/edex-ui-subpackage/node_modules \
|
||||
./src/node_modules
|
||||
# function to resolve symlinks to copies
|
||||
symlinksToCopies() {
|
||||
local dir="$1"
|
||||
|
||||
# transform symlinked subpackage 'node-pty' to copies,
|
||||
# in order to allow re-building
|
||||
mv src/node_modules src/node_modules.bac
|
||||
mkdir src/node_modules
|
||||
cp -r src/node_modules.bac/* src/node_modules/
|
||||
symlinksToCopies ./src/node_modules/node-pty
|
||||
echo "transforming symlinks to copies..."
|
||||
for f in $(find -L "$dir" -xtype l); do
|
||||
if [ -f $f ]; then
|
||||
continue
|
||||
fi
|
||||
echo "copying $f"
|
||||
chmod +wx $(dirname "$f")
|
||||
mv "$f" "$f.bak"
|
||||
mkdir "$f"
|
||||
if [ -n "$(ls -A "$f.bak/")" ]; then
|
||||
cp -r "$f.bak"/* "$f/"
|
||||
chmod -R +w $f
|
||||
fi
|
||||
rm "$f.bak"
|
||||
done
|
||||
}
|
||||
|
||||
# link dependencies of subpackage
|
||||
ln -s \
|
||||
${outputs.subPackages.edex-ui-subpackage.packages.edex-ui-subpackage}/lib/node_modules/edex-ui-subpackage/node_modules \
|
||||
./src/node_modules
|
||||
|
||||
# transform symlinked subpackage 'node-pty' to copies,
|
||||
# in order to allow re-building
|
||||
mv src/node_modules src/node_modules.bac
|
||||
mkdir src/node_modules
|
||||
cp -r src/node_modules.bac/* src/node_modules/
|
||||
symlinksToCopies ./src/node_modules/node-pty
|
||||
'';
|
||||
};
|
||||
};
|
||||
@ -738,26 +759,6 @@ in
|
||||
in "${pkg}/lib/node_modules/${pname}/node_modules")
|
||||
outputs.subPackages))}
|
||||
|
||||
symlinksToCopies() {
|
||||
local dir="$1"
|
||||
|
||||
echo "transforming symlinks to copies..."
|
||||
for f in $(find -L "$dir" -xtype l); do
|
||||
if [ -f $f ]; then
|
||||
continue
|
||||
fi
|
||||
echo "copying $f"
|
||||
chmod +wx $(dirname "$f")
|
||||
mv "$f" "$f.bak"
|
||||
mkdir "$f"
|
||||
if [ -n "$(ls -A "$f.bak/")" ]; then
|
||||
cp -r "$f.bak"/* "$f/"
|
||||
chmod -R +w $f
|
||||
fi
|
||||
rm "$f.bak"
|
||||
done
|
||||
}
|
||||
|
||||
for dir in $(ls -d */); do
|
||||
if [ -f $dir/package.json ]; then
|
||||
echo "installing sub-package $dir"
|
||||
@ -774,12 +775,18 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
# TODO: confirm this is actually working
|
||||
# Allways call tsc --preserveSymlinks
|
||||
# This overrides the argument of tsconfig.json
|
||||
# Is required for installMethod != "copy"
|
||||
typescript = {
|
||||
preserve-symlinks = {
|
||||
postPatch = ''
|
||||
find -name '*.js' -exec \
|
||||
${ensureFileModified} {} sed -i "s/options.preserveSymlinks/true/g; s/compilerOptions.preserveSymlinks/true/g" {} \;
|
||||
postInstall = ''
|
||||
realTsc=$(realpath $out/bin/tsc)
|
||||
rm $out/bin/tsc
|
||||
makeWrapper \
|
||||
$realTsc \
|
||||
$out/bin/tsc \
|
||||
--add-flags " --preserveSymlinks"
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
@ -390,14 +390,6 @@
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# configure typescript
|
||||
if [ -f ./tsconfig.json ] \
|
||||
&& node -e 'require("typescript")' &>/dev/null; then
|
||||
node ${./tsconfig-to-json.js}
|
||||
${pkgs.jq}/bin/jq ".compilerOptions.preserveSymlinks = true" tsconfig.json \
|
||||
| ${pkgs.moreutils}/bin/sponge tsconfig.json
|
||||
fi
|
||||
'';
|
||||
|
||||
# - installs dependencies into the node_modules directory
|
||||
|
@ -1,19 +0,0 @@
|
||||
try {
|
||||
console.log(require.resolve("typescript"));
|
||||
} catch(e) {
|
||||
console.error("typescript is not found");
|
||||
process.exit(e.code);
|
||||
}
|
||||
|
||||
const ts = require("typescript")
|
||||
const fs = require('fs')
|
||||
|
||||
try {
|
||||
const data = fs.readFileSync('tsconfig.json', 'utf8')
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
config = ts.parseConfigFileTextToJson(data)
|
||||
newdata = JSON.stringify(config)
|
||||
fs.writeFileSync('tsconfig.json', newdata);
|
Loading…
Reference in New Issue
Block a user