Skip to content

Commit ada84e0

Browse files
committed
fix: decaffeinate
1 parent f2e04dc commit ada84e0

12 files changed

+8234
-161
lines changed

Diff for: .eslintrc.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module.exports = {
2+
env: {
3+
es6: true,
4+
browser: true,
5+
node: true,
6+
jasmine: true,
7+
atomtest: true,
8+
},
9+
extends: [
10+
'standard',
11+
],
12+
globals: {
13+
atom: 'readonly',
14+
},
15+
parserOptions: {
16+
ecmaVersion: 2018,
17+
},
18+
rules: {
19+
'no-warning-comments': 'warn',
20+
'comma-dangle': ['error', 'always-multiline'],
21+
indent: ['error', 'tab', { SwitchCase: 1 }],
22+
'no-tabs': ['error', { allowIndentationTabs: true }],
23+
'no-restricted-globals': [
24+
'error',
25+
{
26+
name: 'fit',
27+
message: 'Do not commit focused tests.',
28+
},
29+
{
30+
name: 'fdescribe',
31+
message: 'Do not commit focused tests.',
32+
},
33+
],
34+
'no-sync': 'error',
35+
},
36+
}

Diff for: .github/workflows/CI.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: "CI"
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
8+
env:
9+
CI: true
10+
11+
jobs:
12+
Test:
13+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
channel: [stable, beta]
18+
fail-fast: false
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- uses: actions/checkout@v1
22+
- uses: UziTech/action-setup-atom@v1
23+
with:
24+
channel: ${{ matrix.channel }}
25+
- name: Atom version
26+
run: atom -v
27+
- name: APM version
28+
run: apm -v
29+
- name: Install package dependencies
30+
run: apm i minimap
31+
- name: Install dependencies
32+
run: apm ci
33+
- name: Run tests 👩🏾‍💻
34+
run: atom --test spec
35+
36+
Lint:
37+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v1
41+
- uses: actions/setup-node@v1
42+
with:
43+
node-version: '12.x'
44+
- name: NPM install
45+
run: npm ci
46+
- name: Lint ✨
47+
run: npm run lint
48+
49+
# Release:
50+
# needs: [Test, Lint]
51+
# if: |
52+
# github.ref == 'refs/heads/master' &&
53+
# github.event.repository.fork == false
54+
# runs-on: ubuntu-latest
55+
# steps:
56+
# - uses: actions/checkout@v1
57+
# - uses: UziTech/action-setup-atom@v1
58+
# - uses: actions/setup-node@v1
59+
# with:
60+
# node-version: '12.x'
61+
# - name: NPM install
62+
# run: npm ci
63+
# - name: Release 🎉
64+
# env:
65+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
# ATOM_ACCESS_TOKEN: ${{ secrets.ATOM_ACCESS_TOKEN }}
67+
# run: npx semantic-release
68+
69+
Skip:
70+
if: contains(github.event.head_commit.message, '[skip ci]')
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Skip CI 🚫
74+
run: echo skip ci

Diff for: lib/helpers.coffee

-8
This file was deleted.

Diff for: lib/helpers.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { Directory } = require('atom')
2+
3+
module.exports = {
4+
repositoryForPath (goalPath) {
5+
if (goalPath) {
6+
const directory = new Directory(goalPath)
7+
return atom.project.repositoryForDirectory(directory)
8+
}
9+
return Promise.resolve(null)
10+
},
11+
}

Diff for: lib/minimap-git-diff-binding.coffee

-86
This file was deleted.

Diff for: lib/minimap-git-diff-binding.js

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
const { CompositeDisposable } = require('atom')
2+
const { repositoryForPath } = require('./helpers')
3+
4+
class MinimapGitDiffBinding {
5+
constructor (minimap) {
6+
this.active = false
7+
this.updateDiffs = this.updateDiffs.bind(this)
8+
this.destroy = this.destroy.bind(this)
9+
this.minimap = minimap
10+
this.decorations = {}
11+
this.markers = null
12+
this.subscriptions = new CompositeDisposable()
13+
14+
if (!this.minimap) {
15+
console.warn('minimap-git-diff binding created without a minimap')
16+
return
17+
}
18+
19+
this.editor = this.minimap.getTextEditor()
20+
21+
this.subscriptions.add(this.minimap.onDidDestroy(this.destroy))
22+
23+
this.getRepo().then(repo => {
24+
this.repository = repo
25+
if (repo) {
26+
this.subscriptions.add(this.editor.getBuffer().onDidStopChanging(this.updateDiffs))
27+
this.subscriptions.add(this.repository.onDidChangeStatuses(() => {
28+
this.scheduleUpdate()
29+
}))
30+
this.subscriptions.add(this.repository.onDidChangeStatus(changedPath => {
31+
if (changedPath === this.editor.getPath()) { this.scheduleUpdate() }
32+
}))
33+
this.subscriptions.add(this.repository.onDidDestroy(() => {
34+
this.destroy()
35+
}))
36+
this.subscriptions.add(atom.config.observe('minimap-git-diff.useGutterDecoration', useGutterDecoration => {
37+
this.useGutterDecoration = useGutterDecoration
38+
this.scheduleUpdate()
39+
}))
40+
}
41+
})
42+
43+
this.scheduleUpdate()
44+
}
45+
46+
cancelUpdate () {
47+
clearImmediate(this.immediateId)
48+
}
49+
50+
scheduleUpdate () {
51+
this.cancelUpdate()
52+
this.immediateId = setImmediate(this.updateDiffs)
53+
}
54+
55+
updateDiffs () {
56+
this.removeDecorations()
57+
if (this.getPath() && (this.diffs = this.getDiffs())) {
58+
this.addDecorations(this.diffs)
59+
}
60+
}
61+
62+
addDecorations (diffs) {
63+
for (const { newStart, oldLines, newLines } of Array.from(diffs)) {
64+
const startRow = newStart - 1
65+
const endRow = (newStart + newLines) - 2
66+
if ((oldLines === 0) && (newLines > 0)) {
67+
this.markRange(startRow, endRow, '.git-line-added')
68+
} else if ((newLines === 0) && (oldLines > 0)) {
69+
this.markRange(startRow, startRow, '.git-line-removed')
70+
} else {
71+
this.markRange(startRow, endRow, '.git-line-modified')
72+
}
73+
}
74+
}
75+
76+
removeDecorations () {
77+
if (!this.markers) { return }
78+
for (const marker of Array.from(this.markers)) { marker.destroy() }
79+
this.markers = null
80+
}
81+
82+
markRange (startRow, endRow, scope) {
83+
if (this.editor.isDestroyed()) { return }
84+
const marker = this.editor.markBufferRange([[startRow, 0], [endRow, Infinity]], { invalidate: 'never' })
85+
const type = this.useGutterDecoration ? 'gutter' : 'line'
86+
this.minimap.decorateMarker(marker, { type, scope: `.minimap .${type} ${scope}`, plugin: 'git-diff' })
87+
if (!this.markers) { this.markers = [] }
88+
this.markers.push(marker)
89+
}
90+
91+
destroy () {
92+
this.removeDecorations()
93+
this.subscriptions.dispose()
94+
this.diffs = null
95+
this.minimap = null
96+
}
97+
98+
getPath () {
99+
const buffer = this.editor.getBuffer()
100+
if (buffer) {
101+
return buffer.getPath()
102+
}
103+
}
104+
105+
getRepo () { return repositoryForPath(this.editor.getPath()) }
106+
107+
getDiffs () {
108+
try {
109+
const buffer = this.editor.getBuffer()
110+
if (this.repository && buffer) {
111+
return this.repository.getLineDiffs(this.getPath(), buffer.getText())
112+
}
113+
} catch (e) {}
114+
115+
return null
116+
}
117+
}
118+
119+
module.exports = MinimapGitDiffBinding

0 commit comments

Comments
 (0)