2017-09-17 18 views
1

我曾經在Sublime文本中使用構建系統,我可以添加自己的自定義構建系統。例如,對於CLISP,我創建了一個構建系統這樣:在Atom中運行具有特殊條件的腳本

{ 
    "cmd": ["clisp", "-q", "-modern", "-L", "french", "$file"], 
    "selector": "source.lisp" 
} 

同樣,我對C一個自定義的:

{ 
"cmd" : ["gcc $file_name -Wall -o ${file_base_name} && ./${file_base_name}"], 
"selector" : "source.c", 
"shell": true, 
"working_dir" : "$file_path" 
} 

我怎麼能在Atom中做到這一點?

+0

請你告訴使用你的當您完成https://www.reddit.com/r/lisp/ :)時的體驗 – Ehvince

回答

2

對於tthat任務原子有一個好的包凌構建包,你可以在這裏找到:https://github.com/noseglid/atom-build

在此使用JavaScript是一個例子:

module.exports = { 
    cmd: 'make', 
    name: 'Makefile', 
    sh: true, 
    functionMatch: function (output) { 
    const enterDir = /^make\[\d+\]: Entering directory '([^']+)'$/; 
    const error = /^([^:]+):(\d+):(\d+): error: (.+)$/; 
    // this is the list of error matches that atom-build will process 
    const array = []; 
    // stores the current directory 
    var dir = null; 
    // iterate over the output by lines 
    output.split(/\r?\n/).forEach(line => { 
     // update the current directory on lines with `Entering directory` 
     const dir_match = enterDir.exec(line); 
     if (dir_match) { 
     dir = dir_match[1]; 
     } else { 
     // process possible error messages 
     const error_match = error.exec(line); 
     if (error_match) { 
      // map the regex match to the error object that atom-build expects 
      array.push({ 
      file: dir ? dir + '/' + error_match[1] : error_match[1], 
      line: error_match[2], 
      col: error_match[3], 
      message: error_match[4] 
      }); 
     } 
     } 
    }); 
    return array; 
    } 
}; 
相關問題