Append to file


Hi guys I’m new here, I’d like to add a command that will append a file with the selected text, I saw something called fs-plus but when I added fs=require ‘fs-plus’ in my I got the error: Cannot find module ‘fs-plus’

fs = require 'fs-plus'
appendToFile = (selection) ->
  selectedText = selection.getText()
  fs.writeFileSync("C:\\temp.txt", selectedText, {})

im new so please point me out how I can start with development stuff like apm stuff how to install apm and where should i install its modules basic stuff

thanks in advance


You can use Node’s regular fs module for this. Your code will overwrite whatever is in C:\temp.txt with the selected text though, not append it. You would need to use fs.appendFileSync to append the data.