Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
Fix pre commit to only run ts lint if there are ts files modified
Browse files Browse the repository at this point in the history
  • Loading branch information
nakhbari committed Apr 13, 2018
1 parent 87c5a52 commit ac45932
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
19 changes: 12 additions & 7 deletions .pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@ changed_files = `git status --porcelain`
.split(/\n/)
.select { |file_name_with_status| file_name_with_status =~ ADDED_OR_MODIFIED }
.map { |file_name_with_status| file_name_with_status.split(" ")[1] }
.select { |file_name| File.extname(file_name) == ".rb" or OTHER_RUBY_FILES.include?(file_name) }
.join(" ")
changed_ruby_files = changed_files
.select { |file_name| File.extname(file_name) == ".rb" or OTHER_RUBY_FILES.include?(file_name) }
.join(" ")
changed_typescript_files = changed_files
.select { |file_name| File.extname(file_name) == ".ts" }
.join(" ")

exit(0) if changed_files.empty?

unless system("rubocop #{changed_files}")
puts("\n\n💥 Fix ruby linting errors with `rubocop -a` and stage changed, or bypass hook with `git commit --no-verify`")
unless changed_ruby_files.empty? or system("rubocop #{changed_ruby_files}")
puts("\n\n💥 Fix ruby linting errors with `rubocop -a` and stage changed,"\
" or bypass hook with `git commit --no-verify`")
exit($?.exitstatus)
end

unless system("npm run lint")
puts("\n\n💥 Fix js linting errors with `npm run lintfix` and stage changed, or bypass hook with `git commit --no-verify`")
unless changed_typescript_files.empty? or system("npm run lint")
puts("\n\n💥 Fix js linting errors with `npm run lintfix` and stage changed,"\
" or bypass hook with `git commit --no-verify`")
exit($?.exitstatus)
end

exit(0)

2 changes: 1 addition & 1 deletion web/app/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Component, Inject, OnInit} from '@angular/core';
export class DashboardComponent implements OnInit {
constructor(@Inject(DOCUMENT) private document: any) {
this.document.location.href =
`${this.document.location.origin}/dashboard_erb`
`${this.document.location.origin}/dashboard_erb`;
}

ngOnInit() {}
Expand Down
2 changes: 1 addition & 1 deletion web/app/models/project_summary.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BuildStatus, FastlaneStatus, fastlaneStatusToEnum} from '../common/constants'
import {BuildStatus, FastlaneStatus, fastlaneStatusToEnum} from '../common/constants';

export interface ProjectSummaryResponse {
id: string;
Expand Down

0 comments on commit ac45932

Please sign in to comment.