update cleanup (#735)
This commit is contained in:
parent
299417396b
commit
ccc2e33dee
|
@ -20,8 +20,8 @@ const argv = yargs(hideBin(process.argv))
|
||||||
// we need to update the toml file to have a feature on - default=['injective']
|
// we need to update the toml file to have a feature on - default=['injective']
|
||||||
// editing and writing the toml file before building the contract for injective
|
// editing and writing the toml file before building the contract for injective
|
||||||
function injectivePreSetup(contractTomlFilePath: string) {
|
function injectivePreSetup(contractTomlFilePath: string) {
|
||||||
const tomlContentStr = readFileSync(contractTomlFilePath, "utf-8");
|
const originalTomlContentStr = readFileSync(contractTomlFilePath, "utf-8");
|
||||||
const parsedToml = toml.parse(tomlContentStr);
|
const parsedToml = toml.parse(originalTomlContentStr);
|
||||||
|
|
||||||
// add injective feature to the cargo.toml
|
// add injective feature to the cargo.toml
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -38,19 +38,11 @@ function injectivePreSetup(contractTomlFilePath: string) {
|
||||||
});
|
});
|
||||||
|
|
||||||
writeFileSync(contractTomlFilePath, updatedToml);
|
writeFileSync(contractTomlFilePath, updatedToml);
|
||||||
}
|
|
||||||
|
|
||||||
// we are using `git restore` to restore the toml file to it's original content.
|
// after contract compilation we need to reset the original content of the toml file
|
||||||
// we can also remove a feature from parsedToml and stringify it as above.
|
return function injectivePostCleanup() {
|
||||||
// But stringifying it gives us an output with different indentation
|
writeFileSync(contractTomlFilePath, originalTomlContentStr);
|
||||||
// and other such edits.
|
};
|
||||||
function injectivePostCleanup(contractTomlFilePath: string) {
|
|
||||||
exec(`git restore ${contractTomlFilePath}`, (error, _stdout, _stderr) => {
|
|
||||||
if (error !== null)
|
|
||||||
console.log(
|
|
||||||
"Error restoring cargo.toml file. Please restore it manually."
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function build() {
|
function build() {
|
||||||
|
@ -61,14 +53,16 @@ function build() {
|
||||||
|
|
||||||
const contractTomlFilePath = "../contracts/pyth/Cargo.toml";
|
const contractTomlFilePath = "../contracts/pyth/Cargo.toml";
|
||||||
|
|
||||||
if (argv.injective === true) injectivePreSetup(contractTomlFilePath);
|
let cleanup = () => {};
|
||||||
|
if (argv.injective === true)
|
||||||
|
cleanup = injectivePreSetup(contractTomlFilePath);
|
||||||
|
|
||||||
const buildCommand = `
|
const buildCommand = `
|
||||||
docker run --rm -v "$(cd ..; pwd)":/code \
|
docker run --rm -v "$(cd ..; pwd)":/code \
|
||||||
-v $(cd ../../../wormhole_attester; pwd):/wormhole_attester \
|
-v $(cd ../../../wormhole_attester; pwd):/wormhole_attester \
|
||||||
--mount type=volume,source="$(basename "$(cd ..; pwd)")_cache",target=/code/target \
|
--mount type=volume,source="$(basename "$(cd ..; pwd)")_cache",target=/code/target \
|
||||||
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
|
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
|
||||||
cosmwasm/workspace-optimizer-arm64:0.12.11
|
cosmwasm/workspace-optimizer:0.12.11
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// build contract by running the command
|
// build contract by running the command
|
||||||
|
@ -76,7 +70,7 @@ function build() {
|
||||||
console.log(stdout);
|
console.log(stdout);
|
||||||
console.log(stderr);
|
console.log(stderr);
|
||||||
|
|
||||||
if (argv.injective === true) injectivePostCleanup(contractTomlFilePath);
|
cleanup();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue