Created
February 20, 2020 21:51
-
-
Save d3x0r/85e74f69f384c8b50bb3badf1d5df739 to your computer and use it in GitHub Desktop.
gets a directory, opens a file in the directory, and reads, if the file doesn't exist, the read fails, so it writes a default, and then reads again...
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
console.log( "Untested... shell to test" ); | |
const orgRoot = "org.example.domain" | |
const serviceRoot = "data"; | |
const dbRoot = "users"; | |
const appIdentifier = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; | |
var sack = require( "../.." ); | |
//sack.Volume().unlink( "container.vfs" ); | |
var vfs = sack.Volume( "cmount", "container.vfs" ); | |
//console.log( "sack:", sack ); | |
var store = sack.ObjectStorage( vfs, "storage.os" ); | |
console.log( "Store:", store ); | |
var config; | |
store.getDirectory().then( directory=>{ | |
console.log( "DIrectory:", directory ) ; | |
var files = directory.files; // | |
const setConfig = (data)=>{ | |
config = JSOX.parse( data ); | |
console.log( "And finally config:", config ); | |
}; | |
var file = directory.open( "config.jsox" ); | |
file.read().then( setConfig ).catch( ()=>{ | |
file.write( "null" ).then( (done)=>{ | |
console.log( "wrote file?", done ); | |
file.read().then( setConfig ); | |
} ); | |
} ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment