This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isDiff = !!spawnSync('git', ['diff'], getSpawnOptions(rootDir, 'pipe')).stdout.toString().trim(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tag = buildBranch === 'master' ? version : `${version}_${shortSHA}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* checking if branch exists in builds repository */ | |
const isBranchExits = !!spawnSync( | |
'git', | |
['ls-remote', '--exit-code', 'origin', buildBranch], | |
getSpawnOptions(tempDir, 'pipe') | |
).stdout.toString().trim(); | |
if (isBranchExits) { | |
/* checkout the target branch */ | |
spawnSync('git', ['fetch', 'origin', buildBranch], getSpawnOptions(tempDir)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* removing the old build files */ | |
spawnSync( | |
'rm', | |
['-rf', 'lib', 'package.json', 'package-lock.json', 'README.md'], | |
getSpawnOptions(tempDir) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* creating build files copies */ | |
spawnSync('cp', ['-r', 'lib', 'temp/lib'], getSpawnOptions(rootDir)); | |
spawnSync('cp', ['package.json', 'temp/package.json'], getSpawnOptions(rootDir)); | |
spawnSync('cp', ['package-lock.json', 'temp/package-lock.json'], getSpawnOptions(rootDir)); | |
spawnSync('cp', ['README.md', 'temp/README.md'], getSpawnOptions(rootDir)); | |
/* indexing the build files */ | |
spawnSync('git', ['add', '--all'], getSpawnOptions(tempDir)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* message of the last commit in source code repository */ | |
const lastCommitMessage = spawnSync( | |
'git', | |
['log', '--oneline', '-1'], | |
getSpawnOptions(rootDir, 'pipe') | |
).stdout.toString().trim(); | |
/* commit message in build repository */ | |
const message = buildBranch === 'master' ? version : lastCommitMessage; | |
/* making commit in builds repository */ |
OlderNewer