Skip to content

Instantly share code, notes, and snippets.

View qodunpob's full-sized avatar
🥃
Drink Driven Development

Konstantin qodunpob

🥃
Drink Driven Development
View GitHub Profile
/* checking if the created tag exists in build repository */
const isTagExists = !!spawnSync(
'git',
['ls-remote', 'origin', `refs/tags/${tag}`],
getSpawnOptions(tempDir, 'pipe')
).stdout.toString().trim();
const tag = buildBranch === 'master' ? version : `${version}_${shortSHA}`;
/* Shortened hash of the last commit in source code repository.
Used for forming of the unstable version tag */
const shortSHA = spawnSync(
'git',
['rev-parse', '--short', 'HEAD'],
getSpawnOptions(rootDir, 'pipe')
).stdout.toString().trim();
/* current branch name in the module source code repository */
const branch = spawnSync(
'git',
['symbolic-ref', '--short', 'HEAD'],
getSpawnOptions(rootDir, 'pipe')
).stdout.toString().trim();
/* branch name in the builds repository */
const buildBranch = branch === 'develop' ? 'master' : branch;
/* temporary directory for the builds repository */
const tempDir = join(rootDir, 'temp');
if (existsSync(tempDir)) {
spawnSync('rm', ['-rf', 'temp'], getSpawnOptions(rootDir));
}
mkdirSync(tempDir);
/* getting parameters from the package.json */
const { name, version, repository } = require(join(rootDir, 'package.json'));
const originUrl = repository.url.replace(`${name}-source`, name);
const isDiff = !!spawnSync('git', ['diff'], getSpawnOptions(rootDir, 'pipe')).stdout.toString().trim();
import { spawnSync } from 'child_process';
import { mkdirSync, existsSync } from 'fs';
import { join } from 'path';
import chalk from 'chalk';
/**
* Module publication script
*/
/**