fix: improve platform-dependent command execution in grunt tasks
Fixes #2010 # Conflicts: # Gruntfile.js
This commit is contained in:
parent
b435acc6b4
commit
8adcc54070
30
Gruntfile.js
30
Gruntfile.js
@ -4,10 +4,20 @@ const webpack = require("webpack");
|
|||||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||||
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
||||||
const glob = require("glob");
|
const glob = require("glob");
|
||||||
const path = require("path");
|
const path = require("node:path");
|
||||||
|
const cp = require("node:child_process");
|
||||||
|
|
||||||
const nodeFlags = "--no-warnings --no-deprecation";
|
const nodeFlags = "--no-warnings --no-deprecation";
|
||||||
|
|
||||||
|
// Prepare platform-dependent commands
|
||||||
|
|
||||||
|
// Older MacOS versions don't come with `sha256sum`, but they all come with `shasum`
|
||||||
|
const sha256sumCmd = process.platform === "darwin" ? "shasum -a 256" : "sha256sum";
|
||||||
|
|
||||||
|
// MacOS (and FreeBSD, but not OpenBSD) require an argument to `-i`.
|
||||||
|
// However, users may have installed GNU sed, so let's check what `sed` says itself.
|
||||||
|
const sedCmd = cp.execSync("sed -i 2>&1 | head -n1").toString().includes("option requires an argument") ? "sed -i ''" : "sed -i";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grunt configuration for building the app in various formats.
|
* Grunt configuration for building the app in various formats.
|
||||||
*
|
*
|
||||||
@ -334,20 +344,10 @@ module.exports = function (grunt) {
|
|||||||
},
|
},
|
||||||
exec: {
|
exec: {
|
||||||
calcDownloadHash: {
|
calcDownloadHash: {
|
||||||
command: function () {
|
command: chainCommands([
|
||||||
switch (process.platform) {
|
`${sha256sumCmd} build/prod/${downloadZipFilename} | awk '{print $1;}' > build/prod/sha256digest.txt`,
|
||||||
case "darwin":
|
`${sedCmd} -e "s/DOWNLOAD_HASH_PLACEHOLDER/$(cat build/prod/sha256digest.txt)/" build/prod/index.html`,
|
||||||
return chainCommands([
|
]),
|
||||||
`shasum -a 256 build/prod/${downloadZipFilename} | awk '{print $1;}' > build/prod/sha256digest.txt`,
|
|
||||||
`sed -i '' -e "s/DOWNLOAD_HASH_PLACEHOLDER/$(cat build/prod/sha256digest.txt)/" build/prod/index.html`
|
|
||||||
]);
|
|
||||||
default:
|
|
||||||
return chainCommands([
|
|
||||||
`sha256sum build/prod/${downloadZipFilename} | awk '{print $1;}' > build/prod/sha256digest.txt`,
|
|
||||||
`sed -i -e "s/DOWNLOAD_HASH_PLACEHOLDER/$(cat build/prod/sha256digest.txt)/" build/prod/index.html`
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
repoSize: {
|
repoSize: {
|
||||||
command: chainCommands([
|
command: chainCommands([
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user