Atom 在特定目录中使用 API 创建新文件
Atom Create New File using API in Specific Directory
我想做的是在保存之前在特定目录中复制文件。
@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+) .*/,"")
copyPath = atom.config.get("search-the-web.browser.verbose_backup_directory") + editor.buffer.file.path.replace(/(.):/,"\").replace(/(\.(?:.(?!\.))+$)/,"-#{file_prefix}")
console.log(copyPath);
文件文档:https://atom.io/docs/api/v1.31.2/File
目录文档:https://atom.io/docs/api/v1.31.2/Directory
我无法理解 atom.io 网站上的文档,我在互联网上也没有找到任何相关答案,请有人帮忙。我正在使用咖啡脚本
import {File} from 'atom'
const myFile = new File("d:\hello.txt");
myFile.write("testing");
在这里我找到了解决方案。
我想做的是在保存之前在特定目录中复制文件。
@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+) .*/,"")
copyPath = atom.config.get("search-the-web.browser.verbose_backup_directory") + editor.buffer.file.path.replace(/(.):/,"\").replace(/(\.(?:.(?!\.))+$)/,"-#{file_prefix}")
console.log(copyPath);
文件文档:https://atom.io/docs/api/v1.31.2/File
目录文档:https://atom.io/docs/api/v1.31.2/Directory
我无法理解 atom.io 网站上的文档,我在互联网上也没有找到任何相关答案,请有人帮忙。我正在使用咖啡脚本
import {File} from 'atom'
const myFile = new File("d:\hello.txt");
myFile.write("testing");
在这里我找到了解决方案。