2
0
Fork 0
mirror of https://github.com/elementor/hello-theme.git synced 2026-03-03 12:56:14 +08:00
hello-theme/.github/scripts/update-version-in-files.js
ronkelementor e5944194d2
New: Copy GitHub actions from next release for releases (#167)
* New: Add GitHub actions for releases

* delete build + lint workflows
2021-06-21 13:16:26 +03:00

50 lines
1.1 KiB
JavaScript

'use strict';
const replaceInFile = require( 'replace-in-file' );
const { VERSION } = process.env;
const replaceInFileWithLog = async ( options ) => {
const results = await replaceInFile( options );
console.log( 'Replacement results:', results, 'options: ', options );
};
const run = async () => {
try {
await replaceInFileWithLog( {
files: './assets/scss/style.scss',
from: /Version:.*$/m,
to: `Version: ${ VERSION }`,
} );
await replaceInFileWithLog( {
files: './assets/scss/style.scss',
from: /Stable tag:.*$/m,
to: `Stable tag: ${ VERSION }`,
} );
await replaceInFileWithLog( {
files: './functions.php',
from: /HELLO_ELEMENTOR_VERSION', '(.*?)'/m,
to: `HELLO_ELEMENTOR_VERSION', '${ VERSION }'`,
} );
await replaceInFileWithLog( {
files: './readme.txt',
from: /Version:.*$/m,
to: `Version: ${ VERSION }`,
} );
await replaceInFileWithLog( {
files: './readme.txt',
from: /Stable tag:.*$/m,
to: `Stable tag: ${ VERSION }`,
} );
} catch ( err ) {
// eslint-disable-next-line no-console
console.error( 'Error occurred:', err );
process.exit( 1 );
}
};
run();