A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
Read the statement by Michael Teeuw here.
Read local txt file from node_helper.js
-
To conclude this issue, when reading from a local txt file with node_helper.js, you have to make sure the file name has a path. And then when parsing it, you can parse it easily by checking for carriage returns (\r) to see if if its a windows file. Here is a snippet of the solution:
this.rawText = fs.readFileSync(__dirname + '/localTxtFile.txt').toString() this.isWindows = (this.rawText.indexOf('\r') == -1) ? false:true this.variable= this.rawText.split(this.isWindows ? '\r\n\r\n' : '\n\n')
-
@Aphamguin well, you think about what you are trying to accomplish,
I changed the file to Linux line ends. then realized u might get it from somewhere as windows line end. so added to make it work either way.