【问题标题】:Atom Create New File using API in Specific DirectoryAtom 在特定目录中使用 API 创建新文件
【发布时间】:2019-04-13 07:39:52
【问题描述】:

我想要做的是在保存之前在特定目录中制作文件副本。

@sss= new CompositeDisposable
@sss.add atom.workspace.observeTextEditors (editor)=>
    @sss.add editor.buffer.onWillSave => # BUG: this is not working till I lunch web browser
        #if atom.config.get("search-the-web.browser.verbose_backup_directory") is not 'null'
        file_prefix = new Date().toLocaleString().replace(/(\d+)\/(\d+)\/(\d+).*?(\d+):(\d+):(\d+) .*/,"$3$1$2$4$5$6")
        copyPath = atom.config.get("search-the-web.browser.verbose_backup_directory") + editor.buffer.file.path.replace(/(.):/,"\\$1").replace(/(\.(?:.(?!\.))+$)/,"-#{file_prefix}$1")
        console.log(copyPath);

文件文档:https://atom.io/docs/api/v1.31.2/File
目录文档:https://atom.io/docs/api/v1.31.2/Directory

我无法理解 atom.io 网站上的文档,也没有在互联网上找到任何相关答案,请有人帮忙。我正在使用咖啡脚本

【问题讨论】:

    标签: javascript jquery node.js coffeescript atom-editor


    【解决方案1】:
    import {File} from 'atom'
    const myFile = new File("d:\\hello.txt");
    myFile.write("testing");
    

    在这里我找到了解决方案。

    【讨论】:

      猜你喜欢
      • 2012-01-13
      • 1970-01-01
      • 2019-11-16
      • 2018-05-21
      • 2018-07-17
      • 2021-08-31
      • 2013-04-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多