Skip to content

Commit

Permalink
Fix error when trying to highlight files without mime type // format …
Browse files Browse the repository at this point in the history
…code
  • Loading branch information
dmstern committed Nov 26, 2018
1 parent 500a3ff commit d13438f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 37 deletions.
4 changes: 1 addition & 3 deletions server/config-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import Config from '../types/Config';

const homedir = os.homedir();

const configFile = process.env.MOCK
? '.sample.npmfrogrc.json'
: '.npmfrogrc.json';
const configFile = process.env.MOCK ? '.sample.npmfrogrc.json' : '.npmfrogrc.json';
let config: Config;

try {
Expand Down
21 changes: 9 additions & 12 deletions src/views/PackageDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,8 @@
</v-treeview>
</div>
<v-alert
:value="data.activeTreeItem && data.activeTreeItem.size && (
(
(data.activeTreeItem.size > maxSizeToShowContent) ||
!isHighlightableType(data.activeTreeItem)
)
)"
v-if="data.activeTreeItem && data.activeTreeItem.size"
:value="(data.activeTreeItem.size > maxSizeToShowContent) || !isHighlightableType(data.activeTreeItem)"
type="warning"
>
<h3>
Expand All @@ -112,7 +108,7 @@
>
This file is too big to show it's content (> {{maxSizeToShowContent / 1000}} kB).
</span>
<span v-if="!isHighlightableType(data.activeTreeItem)">This filetype ({{data.activeTreeItem.type}}) is not supported.</span>
<span v-if="!isHighlightableType(data.activeTreeItem)">This filetype ({{`${data.activeTreeItem.type}`}}) is not supported.</span>
</h3>
But you can download it here: <ExternalLink :href="`${baseUrl}/packageDetail/${
data.currentPackage ? data.currentPackage.scope : undefined
Expand All @@ -131,7 +127,7 @@
:class="(data.activeTreeItem.name && !isLoadingCode)? 'visible' : 'hidden'"
:key="data.activeTreeItem.id"
:language="getLanguage(data.activeTreeItem.name)"
v-if="data.activeCode !== undefined && data.activeTreeItem.type && isHighlightableType(data.activeTreeItem)"
v-if="data.activeCode !== undefined && isHighlightableType(data.activeTreeItem)"
></CodeBlock>
</div>
</v-card-text>
Expand Down Expand Up @@ -526,10 +522,11 @@ export default class PackageDetail extends Vue {
private isHighlightableType(item: TreeItem): boolean {
return (
item.type !== undefined &&
(item.type.endsWith('json') ||
item.type.endsWith('application/javascript') ||
item.type.startsWith('text'))
item.type === null ||
(item.type !== undefined &&
(item.type.endsWith('json') ||
item.type.endsWith('application/javascript') ||
item.type.startsWith('text')))
);
}
Expand Down
27 changes: 5 additions & 22 deletions types/Crafter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ export default class Crafter extends Searchable {

private static lastUsedColorNumber: number = -1;
private static colors: string[] = Object.keys(vuetifyColors).filter(color => {
return (
!forbiddenColors.some(forbidden => forbidden === color) &&
!color.startsWith('light')
);
return !forbiddenColors.some(forbidden => forbidden === color) && !color.startsWith('light');
});
private static allCrafters: Crafter[] = [];

Expand Down Expand Up @@ -61,9 +58,7 @@ export default class Crafter extends Searchable {
Object.assign(this, author);
}
}
const alreadyCreatedCrafter = Crafter.allCrafters.find(crafter =>
crafter.equals(this),
);
const alreadyCreatedCrafter = Crafter.allCrafters.find(crafter => crafter.equals(this));
if (alreadyCreatedCrafter) {
return alreadyCreatedCrafter;
} else {
Expand All @@ -75,10 +70,7 @@ export default class Crafter extends Searchable {
if (other instanceof Crafter && other.equals(this)) {
return true;
}
if (
other instanceof Package &&
other.crafters.some(crafter => crafter.equals(this))
) {
if (other instanceof Package && other.crafters.some(crafter => crafter.equals(this))) {
return true;
}
for (const item of packages) {
Expand All @@ -101,12 +93,7 @@ export default class Crafter extends Searchable {
`collaborator:${this.name}`,
);
}
text.push(
this.name || '',
this.email || '',
this.url || '',
this.initials || '',
);
text.push(this.name || '', this.email || '', this.url || '', this.initials || '');
return text;
}

Expand All @@ -118,10 +105,6 @@ export default class Crafter extends Searchable {
if (this.email && other.email) {
return this.email === other.email;
}
return (
this.name === other.name &&
this.email === other.email &&
this.url === other.url
);
return this.name === other.name && this.email === other.email && this.url === other.url;
}
}

0 comments on commit d13438f

Please sign in to comment.