Skip to content

Commit

Permalink
Merge pull request #30 from holidayextras/circle-cwd-3
Browse files Browse the repository at this point in the history
use path.join in generateSignedFile.js
  • Loading branch information
hxpaul authored Nov 21, 2017
2 parents f474ec5 + 4783c7c commit cef1cdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions nodeApps/generateSignedFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const git = require('simple-git')()
const releaseBranch = process.env.releaseBranch || 'staging'
const name = process.env.npm_package_name
const version = process.env.npm_package_version
const distPath = path.resolve(process.cwd(), '/dist')
const distPath = path.join(process.cwd(), '/dist')

const checkPrerequisites = callback => {
if (!process.env.npm_package_name) return callback('ERROR: run this as an npm script (npm run release)')
Expand Down Expand Up @@ -46,7 +46,7 @@ const checkBranch = callback => {
const checkAlreadyReleased = callback => {
const fullPath = path.resolve(`${distPath}/${name}.min.${version}.js`)
if (fs.existsSync(fullPath)) {
return callback(`Already exported ${name}.min.${version}.js`)
return callback(`Already exported ${distPath}${name}.min.${version}.js`)
}
callback()
}
Expand Down Expand Up @@ -74,11 +74,12 @@ const getSignedProductionFile = getSignature.bind(null, `${distPath}/${name}.min
const updateChangelog = (versionedFile, signature, callback) => {
fs.readFile('CHANGELOG.md', 'utf-8', (readErr, contents) => {
if (readErr) return callback(readErr)
const existingLines = new RegExp(`.*${versionedFile}.*`, 'g')
const file = ('' + versionedFile).replace(distPath, '')
const existingLines = new RegExp(`.*${file}.*`, 'g')
const newContents = contents
.replace(existingLines, '')
.replace(/\n\s*\n/g, '\n')
.replace('# Changelog', `# Changelog \n\n- ${versionedFile} - signature: ${signature}`)
.replace('# Changelog', `# Changelog \n\n- ${file} - signature: ${signature}`)
fs.writeFile('CHANGELOG.md', newContents, function (writeErr) {
if (writeErr) return callback(writeErr)
callback()
Expand All @@ -92,8 +93,8 @@ const addFile = (file, callback) => {
})
}

const addStagingFile = addFile.bind(null, `dist/${name}.staging.min.${version}.js`)
const addProductionFile = addFile.bind(null, `dist/${name}.min.${version}.js`)
const addStagingFile = addFile.bind(null, `${distPath}/${name}.staging.min.${version}.js`)
const addProductionFile = addFile.bind(null, `${distPath}/${name}.min.${version}.js`)
const addChangelog = addFile.bind(null, 'CHANGELOG.md')

const commit = callback => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deployment-helpers",
"version": "1.7.2",
"version": "1.7.3",
"description": "A collection of scripts that can be used as part of a deployment process.",
"main": "src/utils",
"bin": {
Expand Down

0 comments on commit cef1cdd

Please sign in to comment.