misty
This commit is contained in:
28
resources.cm
28
resources.cm
@@ -23,24 +23,24 @@ Resources.lib = [".so", ".dll", ".dylib"]
|
||||
function getExtension(path) {
|
||||
var idx = path.lastIndexOf('.')
|
||||
if (idx < 0) return ''
|
||||
return path.substring(idx + 1).toLowerCase()
|
||||
return lower(text(path, idx + 1))
|
||||
}
|
||||
|
||||
// Return true if ext is in at least one of the recognized lists
|
||||
function isRecognizedExtension(ext) {
|
||||
if (!ext) return false
|
||||
if (Resources.scripts.includes(ext)) return true
|
||||
if (Resources.images.includes(ext)) return true
|
||||
if (Resources.sounds.includes(ext)) return true
|
||||
if (Resources.fonts.includes(ext)) return true
|
||||
if (Resources.lib.includes('.' + ext)) return true // for .so or .dll
|
||||
if (search(Resources.scripts, ext) != null) return true
|
||||
if (search(Resources.images, ext) != null) return true
|
||||
if (search(Resources.sounds, ext) != null) return true
|
||||
if (search(Resources.fonts, ext) != null) return true
|
||||
if (search(Resources.lib, '.' + ext) != null) return true // for .so or .dll
|
||||
return false
|
||||
}
|
||||
|
||||
function find_in_path(filename, exts = []) {
|
||||
if (!is_text(filename)) return null
|
||||
|
||||
if (filename.includes('.')) {
|
||||
if (search(filename, '.') != null) {
|
||||
var candidate = filename // possibly need "/" ?
|
||||
if (io.exists(candidate) && !io.is_directory(candidate)) return candidate
|
||||
return null
|
||||
@@ -87,10 +87,10 @@ function read_ignore(dir) {
|
||||
var path = dir + '/.prosperonignore'
|
||||
var patterns = []
|
||||
if (io.exists(path)) {
|
||||
var lines = io.slurp(path).split('\n')
|
||||
var lines = array(io.slurp(path), '\n')
|
||||
for (var line of lines) {
|
||||
line = line.trim()
|
||||
if (!line || line.startsWith('#')) continue
|
||||
line = trim(line)
|
||||
if (!line || starts_with(line, '#')) continue
|
||||
patterns.push(line)
|
||||
}
|
||||
}
|
||||
@@ -124,19 +124,19 @@ Resources.gatherStats = function(filePaths) {
|
||||
}
|
||||
for (var path of filePaths) {
|
||||
var ext = getExtension(path)
|
||||
if (Resources.scripts.includes(ext)) {
|
||||
if (find(Resources.scripts, ext) != null) {
|
||||
stats.scripts++
|
||||
continue
|
||||
}
|
||||
if (Resources.images.includes(ext)) {
|
||||
if (find(Resources.images, ext) != null) {
|
||||
stats.images++
|
||||
continue
|
||||
}
|
||||
if (Resources.sounds.includes(ext)) {
|
||||
if (find(Resources.sounds, ext) != null) {
|
||||
stats.sounds++
|
||||
continue
|
||||
}
|
||||
if (Resources.fonts.includes(ext)) {
|
||||
if (find(Resources.fonts, ext) != null) {
|
||||
stats.fonts++
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user