Last active
September 30, 2020 06:33
-
-
Save nsisodiya/aea76052762ff1c764d41f0fcf0bc57e to your computer and use it in GitHub Desktop.
./system/npm/fix-version-lock.js
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 fs = require('fs'); | |
const YAML = require('yamljs'); | |
const replaceFirstLineOfFile = require('file-firstline-replace'); | |
const pkgJson = require('../../package.json'); | |
var filename = 'Dockerfile'; | |
var newHeader = `FROM node:${pkgJson.nodeVersionLock} as builder\n`; | |
replaceFirstLineOfFile(filename, newHeader, function (error) { | |
if (error) { | |
throw error; | |
} | |
console.warn('Dockerfile updated'); | |
}); | |
// Replace in gitlab ci file. | |
var gitlabCiYml = fs.readFileSync('.github/workflows/node.js.yml', 'utf8'); | |
// parse YAML string | |
var gitlabCiJSON = YAML.parse(gitlabCiYml); | |
gitlabCiJSON.jobs.build.strategy.matrix['node-version'][0] = pkgJson.nodeVersionLock; | |
var spaces = 4; | |
var gitlabCiYmlUpdated = YAML.stringify(gitlabCiJSON, spaces); | |
fs.writeFileSync('.github/workflows/node.js.yml', gitlabCiYmlUpdated, 'utf8'); | |
console.warn('github CI file updated'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment