-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathutils.js
More file actions
27 lines (23 loc) · 816 Bytes
/
utils.js
File metadata and controls
27 lines (23 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
* Copyright (c) 2023, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
const sh = require('shelljs')
const saveJSONToFile = (json, filePath) => {
const jsonString = JSON.stringify(json, null, 2)
// Make sure there's a newline at end of file
new sh.ShellString(`${jsonString}\n`).to(filePath)
}
const setPackageVersion = (version, shellOptions = {}) => {
sh.exec(`npm version --no-git-tag ${version}`, {silent: true, ...shellOptions})
}
const getLatestVersion = (pkgName) => {
return sh.exec(`npm info ${pkgName}@latest version`, {silent: true}).trim()
}
module.exports = {
saveJSONToFile,
setPackageVersion,
getLatestVersion
}