Merge remote-tracking branch 'upstream/release-7.5.0' into chore/merge-release-into-dev
This commit is contained in:
commit
0ad2ee362a
109 changed files with 3283 additions and 697 deletions
34
bin/lamassu-update-cassettes
Normal file
34
bin/lamassu-update-cassettes
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const _ = require('lodash')
|
||||
const db = require('../lib/db')
|
||||
|
||||
if (process.argv.length !== 4) {
|
||||
console.log('Usage: lamassu-update-cassettes <device_id> <number_of_cassettes>')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (!_.isFinite(parseInt(process.argv[3]))) {
|
||||
console.log('Error: <number_of_cassettes> is not a valid number (%s)', err)
|
||||
process.exit(3)
|
||||
}
|
||||
|
||||
if (parseInt(process.argv[3]) > 4 || parseInt(process.argv[3]) < 2) {
|
||||
console.log('Error: <number_of_cassettes> is out of range. Should be a number between 2 and 4')
|
||||
process.exit(3)
|
||||
}
|
||||
|
||||
const deviceId = process.argv[2]
|
||||
const numberOfCassettes = parseInt(process.argv[3])
|
||||
|
||||
const query = `UPDATE devices SET number_of_cassettes = $1 WHERE device_id = $2`
|
||||
|
||||
db.none(query, [numberOfCassettes, deviceId])
|
||||
.then(() => {
|
||||
console.log('Success! Device %s updated to %s cassettes', deviceId, numberOfCassettes)
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('Error: %s', err)
|
||||
process.exit(3)
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue