Push dev work to master #2
|
@ -83,24 +83,26 @@ class Wifi {
|
||||||
*/
|
*/
|
||||||
_readConfigCb (err, data) {
|
_readConfigCb (err, data) {
|
||||||
let parsed
|
let parsed
|
||||||
|
let current
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
return _cb(err)
|
return _cb(err)
|
||||||
}
|
}
|
||||||
|
console.log(data)
|
||||||
parsed = parseConfig(data)
|
parsed = parseConfig(data)
|
||||||
console.dir(parsed)
|
console.dir(parsed)
|
||||||
console.log(data)
|
current = parsed.filter(network => {
|
||||||
console.log(data.search(networkPattern))
|
return (network.ssid + '').toLowerCase() === (_ssid + '').toLowerCase()
|
||||||
console.log(_entry)
|
})
|
||||||
|
console.log(current)
|
||||||
if (data.search(networkPattern) === -1) {
|
if (typeof current !== 'undefined') {
|
||||||
data += `\n${_entry}`
|
data = data.replace(current.raw, _entry)
|
||||||
} else {
|
} else {
|
||||||
data = data.replace(networkPattern, _entry)
|
data += '\n\n' + _entry
|
||||||
}
|
}
|
||||||
console.dir(data)
|
console.log(data)
|
||||||
_entry = null
|
_entry = null
|
||||||
|
this._writeConfigCb(null)
|
||||||
//fs.writeFile(filePath, data, 'utf8', this._writeConfigCb)
|
//fs.writeFile(filePath, data, 'utf8', this._writeConfigCb)
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue