Skip to content

Commit

Permalink
fix: simplified the code
Browse files Browse the repository at this point in the history
  • Loading branch information
luthfimasruri committed Mar 25, 2021
1 parent e507529 commit 678c9e0
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions prebuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const pkg = require('./package.json')

const getNextVersion = async (): Promise<string> => {
try {
const result = await semanticRelease({
const { nextRelease } = await semanticRelease({
// Core options
branches: releaserc.branches,
repositoryUrl: pkg.repository.url,
Expand All @@ -13,12 +13,8 @@ const getNextVersion = async (): Promise<string> => {
plugins: ['@semantic-release/commit-analyzer']
});

console.log("PROCESS_ENV_CI ---->>>>>>>>>>", process.env.CI);

if (result) {
const { lastRelease, commits, nextRelease } = result;
console.log(`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`);
if (lastRelease.version) console.log(`The last release was "${lastRelease.version}".`);
if (nextRelease) {
console.log(`Published ${nextRelease.type} release version ${nextRelease.version}.`);
return nextRelease.version
} else {
console.log('No release published.');
Expand All @@ -29,20 +25,19 @@ const getNextVersion = async (): Promise<string> => {
return ""
}

const fs = require('fs');
const csso = require('csso');
const packageConfigs = async () => {
return {
version: await getNextVersion()
if (!process.env.CI) {
const fs = require('fs');
const getPackageConfigs = async () => {
return { version: await getNextVersion() }
}
}

const prebuildPkg = 'temp/prebuild-package.json'
if (!fs.existsSync("temp")) fs.mkdirSync("temp");
packageConfigs().then((config) => {
const content = JSON.stringify(config)
fs.writeFile(prebuildPkg, content, (err: any) => {
if (err) throw err;
console.log('empty.js created');
const pkgFileName = 'temp/prebuild-package.json'
if (!fs.existsSync("temp")) fs.mkdirSync("temp");
getPackageConfigs().then((config) => {
const content = JSON.stringify(config)
fs.writeFile(pkgFileName, content, (err: any) => {
if (err) throw err;
console.log(`${pkgFileName} created`);
})
})
})
}

0 comments on commit 678c9e0

Please sign in to comment.