in generators/app/generate-colortheme.js [139:188]
function convertTheme(location, extensionConfig, inline, generator) {
if (!location) {
extensionConfig.tmThemeFileName = '';
extensionConfig.tmThemeContent = '';
} else if (location.match(/\w*:\/\//)) {
// load from url
return request.xhr({ url: location }).then(r => {
if (r.status == 200) {
var tmThemeFileName = null;
if (!inline) {
var contentDisposition = r.headers && r.headers['content-disposition'];
if (contentDisposition) {
var fileNameMatch = contentDisposition.match(/filename="([^"]*)/);
if (fileNameMatch) {
tmThemeFileName = fileNameMatch[1];
}
}
if (!tmThemeFileName) {
var lastSlash = location.lastIndexOf('/');
if (lastSlash) {
tmThemeFileName = location.substr(lastSlash + 1);
} else {
tmThemeFileName = 'theme.tmTheme';
}
}
}
return processContent(extensionConfig, tmThemeFileName, r.responseText, generator);
} else {
return Promise.reject("Problems loading theme: HTTP status " + r.status);
}
});
} else {
// load from disk
var body = null;
try {
body = fs.readFileSync(location);
} catch (error) {
return Promise.reject("Problems loading theme: " + error.message);
}
if (body) {
var fileName = null;
if (!inline) {
fileName = path.basename(location);
}
return processContent(extensionConfig, fileName, body.toString(), generator);
} else {
return Promise.reject("Problems loading theme: Not found");
}
}
}