Last active
December 19, 2015 23:29
-
-
Save oklai/6034902 to your computer and use it in GitHub Desktop.
Koala compiler data structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// A version of the properties for displaying. | |
// @optional | |
// e.g. "Stylus" | |
"name": "My", | |
// The version of this extension. | |
// @type {String} | |
"version": "1.0.0", | |
"compiler_version": "0.3.0", | |
"koala": ">=1.5.0", | |
// The file types defined by this package. | |
// @type {Array.<FileType>|FileType} | |
// @optional | |
"file_type": [{ | |
"input": "my", | |
"output": "txt", | |
"icons": "./icon/my.png" | |
}, | |
{ | |
"input": "me", | |
"output": "txt", | |
"icons": "./icon/me.png" | |
}], | |
// The relative path to the compiler class, relative to this file. | |
// @type {String} | |
"class_path": "MyCompiler.js", | |
"use_system_command": false, | |
"options": [ | |
{ | |
"type": "single", | |
"name": "lineComments", | |
"display": "line comments", | |
"default": false | |
}, | |
{ | |
"type": "single", | |
"name": "debugInfo", | |
"display": "debug info", | |
"default": true | |
}, | |
{ | |
"type": "multiple", | |
"name": "outputStyle", | |
"display": "output style", | |
"values": [ | |
{ | |
"display": "normal", | |
"value": "" | |
}, | |
{ | |
"display": "compress", | |
"value": "compress" | |
}, | |
{ | |
"display": "yuicompress", | |
"value": "yuicompress" | |
} | |
], | |
"default": "compress" | |
} | |
], | |
// The author info. | |
// @type {Object} | |
"maintainers": { | |
"name": "", | |
"email": "", | |
"web": "", | |
"project": "http://github.com/..." | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// file types object of Koala internal data structures | |
// var fileTypes = getAllFileTypes() | |
// console.log(fileTypes) | |
{ | |
"sass": { | |
"output": "css", | |
"icons": "./icon/sass.png", | |
"compiler": "sass" | |
}, | |
"scss": { | |
"output": "css", | |
"icons": "./icon/scss.png", | |
"compiler": "sass" | |
}, | |
"less": { | |
"output": "css", | |
"icons": "./icon/less.png", | |
"compiler": "less" | |
}, | |
"styl": { | |
"output": "css", | |
"icons": "./icon/jade.png", | |
"compiler": "stylus" | |
}, | |
"jade": { | |
"output": "html", | |
"icons": "./icon/jade.png", | |
"compiler": "jade" | |
} | |
} | |
// compilers object of Koala internal data structures | |
// var compilers = getAllCompilers() | |
// console.log(compilers) | |
{ | |
"less": { | |
"name": "less", | |
"version": "1.0.0", | |
"compiler_version": "0.3.0", | |
"koala": ">=1.5.0", | |
"file_type": [{ | |
"input": "less", | |
"output": "css", | |
"icons": "../icon/my.png" | |
}], | |
"class_path": "LessCompiler.js", | |
"use_system_command": false, | |
"options": [ | |
{ | |
"type": "single", | |
"name": "lineComments", | |
"display": "line comments", | |
"default": false | |
}, | |
{ | |
"type": "single", | |
"name": "debugInfo", | |
"display": "debug info", | |
"default": true | |
}, | |
{ | |
"type": "multiple", | |
"name": "outputStyle", | |
"display": "output style", | |
"values": [ | |
{ | |
"display": "normal", | |
"value": "" | |
}, | |
{ | |
"display": "compress", | |
"value": "compress" | |
}, | |
{ | |
"display": "yuicompress", | |
"value": "yuicompress" | |
} | |
], | |
"default": "compress" | |
} | |
] | |
}, | |
"sass": { | |
"name": "sass", | |
"version": "1.0.0", | |
"compiler_version": "0.3.0", | |
"koala": ">=1.5.0", | |
"file_type": [{ | |
"input": "sass", | |
"output": "css", | |
"icons": "../icon/sass.png" | |
},{ | |
"input": "scss", | |
"output": "css", | |
"icons": "../icon/scss.png" | |
}], | |
"class_path": "SassCompiler.js", | |
"use_system_command": false, | |
"options": [ | |
// options here | |
] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create file object | |
var fileTypes = getAllFileTypes(); | |
var compilers = getAllCompilers(); | |
var creatFileObject = function (fileSrc, config) { | |
var ext = path.extname(fileSrc).substr(1); | |
var fileType = fileTypes[ext]; | |
var compiler = compilers[fileType.compiler]; | |
var output = fileSrc.replace(ext, fileType.output); | |
var settings = {}; | |
//apply global settings | |
if (appConfig[fileType.name]) { | |
for (var key in appConfig[fileType.name]) { | |
settings[key] = appConfig[fileType.name][key]; | |
} | |
} | |
//apply project settings | |
for (var m in config.options) { | |
settings[m] = config.options[m]; | |
} | |
return { | |
id: util.createRdStr(), | |
pid: '', | |
type: compiler.name, | |
name: path.basename(fileSrc), | |
src: fileSrc, | |
output: output, | |
compile: true, | |
settings: settings | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In "compiler.package.text":
"koala": ">=1.5.0"