Getting .old file after running command


I am developing a package for an in house language. We have an existing code formatter I would like to use. I can call the formatter from Atom on the open file but once done the open file is renamed my-file.fs to my-file.fs.old. The original file has been formatted which I see if a reopen it. Here’s the code I use to call the code formatter.

  format() {
    // get the TextEditor object
    let editor = atom.workspace.getActivePaneItem();
    let file = editor ? editor.buffer.file : null;
    let filePath = file ? file.path : null;
    let command = "C:\\Utilities\\execute.bat";
    let args = ["C:\\Utilities\\interpreter.exe","C:\\Utilities\\formatany.mas",filePath];
    console.log('format any cmd line is ' + command + " " + args);
    let options = {
      cwd: "C:\\Utilities"
    let stdout = (output) => console.log(output);
    let stderr = (output) => console.error(output);

    let exit = (return_code) => {
      if (return_code === 0) {
        console.log("Exited with 0");
        console.log("Exited with " + return_code);
    // save file before format;
    let bufferedProcess = new BufferedProcess({command, args, options, stdout, stderr, exit});

Ideally the file would reload after the BufferedProcess exits.


So if the formatter moves the file, can you:

  1. Copy the contents of the file to be formatted someplace else
  2. Run the formatter on the temporary file
  3. Take the formatted code out of the formatted temporary file
  4. Replace the contents of the current file with the formatted contents

Would that work?


Ah, Atom is handling a file rename in a way that Sublime and Textapd do not. I’ve never seen this behavior before and assumed Atom was backing up the file. It’s definitely in the format program. Thanks again.