jan/electron/merge-latest-ymls.js
hiento09 4f751338b7
Regression fix assitant extension codesign (#1918)
* Separated build macos arm64 and x86_x64

* Update dependencies jobs name

* Remove arch from electron-builder command for mac

* Add combine latest-mac.yml jobs

* Remove unuse workflow job

* Add prefix to install js-yaml

* Run merge script from /tmp

* workflow update release draft depend on combile-latest-mac

* correct template path

* upload assert release latest-mac.yml overwrite set to true

* upload assert release latest-mac.yml overwrite set to true

* Grant permission for combine latest-mac jobs

---------

Co-authored-by: Hien To <hien@jan.ai>
2024-02-04 15:44:57 +07:00

28 lines
755 B
JavaScript

const yaml = require('js-yaml')
const fs = require('fs')
// get two file paths from arguments:
const [, , ...args] = process.argv
const file1 = args[0]
const file2 = args[1]
const file3 = args[2]
// check that all arguments are present and throw error instead
if (!file1 || !file2 || !file3) {
throw new Error('Please provide 3 file paths as arguments: path to file1, to file2 and destination path')
}
const doc1 = yaml.load(fs.readFileSync(file1, 'utf8'))
console.log('doc1: ', doc1)
const doc2 = yaml.load(fs.readFileSync(file2, 'utf8'))
console.log('doc2: ', doc2)
const merged = { ...doc1, ...doc2 }
merged.files.push(...doc1.files)
console.log('merged', merged)
const mergedYml = yaml.dump(merged)
fs.writeFileSync(file3, mergedYml, 'utf8')