Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: prettier/pretty-quick
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.0
Choose a base ref
...
head repository: prettier/pretty-quick
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.0.1
Choose a head ref
  • 8 commits
  • 15 files changed
  • 4 contributors

Commits on Oct 13, 2019

  1. chore(deps): bump sshpk from 1.13.1 to 1.16.1 (#81)

    Bumps [sshpk](https://github.com/joyent/node-sshpk) from 1.13.1 to 1.16.1.
    - [Release notes](https://github.com/joyent/node-sshpk/releases)
    - [Commits](TritonDataCenter/node-sshpk@v1.13.1...v1.16.1)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and azz committed Oct 13, 2019
    Copy the full SHA
    0e4bc04 View commit details
  2. chore(deps): bump nwmatcher from 1.4.3 to 1.4.4 (#78)

    Bumps [nwmatcher](https://github.com/dperini/nwmatcher) from 1.4.3 to 1.4.4.
    - [Release notes](https://github.com/dperini/nwmatcher/releases)
    - [Commits](https://github.com/dperini/nwmatcher/commits)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: null <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored and azz committed Oct 13, 2019
    Copy the full SHA
    be91e96 View commit details
  3. Copy the full SHA
    65dfdde View commit details
  4. chore(deps): bump extend from 3.0.1 to 3.0.2 (#80)

    Bumps [extend](https://github.com/justmoon/node-extend) from 3.0.1 to 3.0.2.
    - [Release notes](https://github.com/justmoon/node-extend/releases)
    - [Changelog](https://github.com/justmoon/node-extend/blob/master/CHANGELOG.md)
    - [Commits](justmoon/node-extend@v3.0.1...v3.0.2)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: null <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored and azz committed Oct 13, 2019
    Copy the full SHA
    4e80800 View commit details
  5. chore(deps): bump hoek from 4.2.0 to 4.2.1 (#86)

    Bumps [hoek](https://github.com/hapijs/hoek) from 4.2.0 to 4.2.1.
    - [Release notes](https://github.com/hapijs/hoek/releases)
    - [Changelog](https://github.com/hapijs/hoek/blob/master/CHANGELOG.md)
    - [Commits](hapijs/hoek@v4.2.0...v4.2.1)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and azz committed Oct 13, 2019
    Copy the full SHA
    a8dfa9e View commit details
  6. 1
    Copy the full SHA
    02438dc View commit details
  7. chore: update package.json (#89)

    fisker authored and azz committed Oct 13, 2019
    Copy the full SHA
    6862b20 View commit details

Commits on Nov 5, 2019

  1. Copy the full SHA
    3370668 View commit details
Showing with 87 additions and 61 deletions.
  1. +9 −7 .eslintrc.yml
  2. +0 −1 .prettierignore
  3. +0 −2 .prettierrc.yml
  4. +1 −1 LICENSE
  5. +7 −7 bin/pretty-quick.js
  6. +4 −2 package.json
  7. +1 −1 src/__tests__/pretty-quick.test.js
  8. +7 −7 src/__tests__/scm-git.test.js
  9. +5 −5 src/__tests__/scm-hg.test.js
  10. +1 −1 src/index.js
  11. +1 −1 src/isSupportedExtension.js
  12. +2 −2 src/processFiles.js
  13. +9 −4 src/scms/git.js
  14. +1 −1 src/scms/hg.js
  15. +39 −19 yarn.lock
16 changes: 9 additions & 7 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
extends:
- eslint:recommended
- plugin:jest/recommended
- plugin:prettier/recommended
- eslint:recommended
- plugin:jest/recommended
- plugin:prettier/recommended
env:
es6: true
node: true
parserOptions:
ecmaVersion: 2019
rules:
no-console: off
no-console: 0
overrides:
- files: "src/**/*.js"
parserOptions:
sourceType: module
- files: 'src/**/*.js'
parserOptions:
sourceType: module
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

2 changes: 0 additions & 2 deletions .prettierrc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Lucas Azzola
Copyright (c) 2017- Lucas Azzola

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
14 changes: 7 additions & 7 deletions bin/pretty-quick.js
Original file line number Diff line number Diff line change
@@ -15,16 +15,16 @@ const prettyQuickResult = prettyQuick(
onFoundSinceRevision: (scm, revision) => {
console.log(
`🔍 Finding changed files since ${chalk.bold(
scm
)} revision ${chalk.bold(revision)}.`
scm,
)} revision ${chalk.bold(revision)}.`,
);
},

onFoundChangedFiles: changedFiles => {
console.log(
`🎯 Found ${chalk.bold(changedFiles.length)} changed ${
changedFiles.length === 1 ? 'file' : 'files'
}.`
}.`,
);
},

@@ -45,7 +45,7 @@ const prettyQuickResult = prettyQuick(
onExamineFile: file => {
console.log(`🔍 Examining ${chalk.bold(file)}.`);
},
})
}),
);

if (prettyQuickResult.success) {
@@ -54,17 +54,17 @@ if (prettyQuickResult.success) {
if (prettyQuickResult.errors.indexOf('PARTIALLY_STAGED_FILE') !== -1) {
console.log(
'✗ Partially staged files were fixed up.' +
` ${chalk.bold('Please update stage before committing')}.`
` ${chalk.bold('Please update stage before committing')}.`,
);
}
if (prettyQuickResult.errors.indexOf('BAIL_ON_WRITE') !== -1) {
console.log(
'✗ File had to be prettified and prettyQuick was set to bail mode.'
'✗ File had to be prettified and prettyQuick was set to bail mode.',
);
}
if (prettyQuickResult.errors.indexOf('CHECK_FAILED') !== -1) {
console.log(
'✗ Code style issues found in the above file(s). Forgot to run Prettier?'
'✗ Code style issues found in the above file(s). Forgot to run Prettier?',
);
}
process.exit(1); // ensure git hooks abort
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -46,12 +46,14 @@
"hooks": {
"pre-commit": "./bin/pretty-quick.js --staged"
}
},
},
"prettier": "@azz/prettier-config",
"peerDependencies": {
"prettier": ">=1.8.0"
},
"devDependencies": {
"@babel/cli": "^7.6 .4",
"@azz/prettier-config": "^1.0.0",
"@babel/cli": "^7.6.4",
"@babel/core": "^7.6.4",
"@babel/preset-env": "^7.6.3",
"eslint": "^5.16.0",
2 changes: 1 addition & 1 deletion src/__tests__/pretty-quick.test.js
Original file line number Diff line number Diff line change
@@ -12,6 +12,6 @@ test('throws an error when no vcs is found', () => {
});

expect(() => prettyQuick('root')).toThrow(
'Unable to detect a source control manager.'
'Unable to detect a source control manager.',
);
});
14 changes: 7 additions & 7 deletions src/__tests__/scm-git.test.js
Original file line number Diff line number Diff line change
@@ -20,8 +20,8 @@ const mockGitFs = (additionalUnstaged = '', additionalFiles = {}) => {
'/foo.js': 'foo()',
'/bar.md': '# foo',
},
additionalFiles
)
additionalFiles,
),
);
execa.sync.mockImplementation((command, args) => {
if (command !== 'git') {
@@ -53,7 +53,7 @@ describe('with git', () => {
expect(execa.sync).toHaveBeenCalledWith(
'git',
['merge-base', 'HEAD', 'master'],
{ cwd: '/' }
{ cwd: '/' },
);
});

@@ -68,7 +68,7 @@ describe('with git', () => {
expect(execa.sync).toHaveBeenCalledWith(
'git',
['merge-base', 'HEAD', 'master'],
{ cwd: '/' }
{ cwd: '/' },
);
});

@@ -96,7 +96,7 @@ describe('with git', () => {
expect(execa.sync).toHaveBeenCalledWith(
'git',
['diff', '--name-only', '--diff-filter=ACMRTUB'],
{ cwd: '/' }
{ cwd: '/' },
);
});

@@ -110,7 +110,7 @@ describe('with git', () => {
expect(execa.sync).toHaveBeenCalledWith(
'git',
['diff', '--name-only', '--diff-filter=ACMRTUB', 'banana'],
{ cwd: '/' }
{ cwd: '/' },
);
});

@@ -124,7 +124,7 @@ describe('with git', () => {
expect(execa.sync).toHaveBeenCalledWith(
'git',
['ls-files', '--others', '--exclude-standard'],
{ cwd: '/' }
{ cwd: '/' },
);
});

10 changes: 5 additions & 5 deletions src/__tests__/scm-hg.test.js
Original file line number Diff line number Diff line change
@@ -19,8 +19,8 @@ const mockHgFs = (additionalFiles = {}) => {
'/foo.js': 'foo()',
'/bar.md': '# foo',
},
additionalFiles
)
additionalFiles,
),
);
execa.sync.mockImplementation((command, args) => {
if (command !== 'hg') {
@@ -52,7 +52,7 @@ describe('with hg', () => {
expect(execa.sync).toHaveBeenCalledWith(
'hg',
['debugancestor', 'tip', 'default'],
{ cwd: '/' }
{ cwd: '/' },
);
});

@@ -66,7 +66,7 @@ describe('with hg', () => {
expect(execa.sync).toHaveBeenCalledWith(
'hg',
['debugancestor', 'tip', 'default'],
{ cwd: '/' }
{ cwd: '/' },
);
});

@@ -80,7 +80,7 @@ describe('with hg', () => {
expect(execa.sync).toHaveBeenCalledWith(
'hg',
['status', '-n', '-a', '-m', '--rev', 'banana'],
{ cwd: '/' }
{ cwd: '/' },
);
});

2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ export default (
onExamineFile,
onCheckFile,
onWriteFile,
} = {}
} = {},
) => {
const scm = scms(currentDirectory);
if (!scm) {
2 changes: 1 addition & 1 deletion src/isSupportedExtension.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import { getSupportInfo } from 'prettier';

const extensions = getSupportInfo().languages.reduce(
(prev, language) => prev.concat(language.extensions || []),
[]
[],
);

export default file => extensions.includes(extname(file));
4 changes: 2 additions & 2 deletions src/processFiles.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import { join } from 'path';
export default (
directory,
files,
{ check, config, onExamineFile, onCheckFile, onWriteFile } = {}
{ check, config, onExamineFile, onCheckFile, onWriteFile } = {},
) => {
for (const relative of files) {
onExamineFile && onExamineFile(relative);
@@ -16,7 +16,7 @@ export default (
config,
editorconfig: true,
}),
{ filepath: file }
{ filepath: file },
);
const input = readFileSync(file, 'utf8');

13 changes: 9 additions & 4 deletions src/scms/git.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import findUp from 'find-up';
import execa from 'execa';
import { dirname } from 'path';
import { dirname, join } from 'path';
import * as fs from 'fs';

export const name = 'git';

export const detect = directory => {
if (fs.existsSync(join(directory, '.git'))) {
return directory;
}

const gitDirectory = findUp.sync('.git', {
cwd: directory,
type: 'directory',
@@ -53,13 +58,13 @@ export const getChangedFiles = (directory, revision, staged) => {
staged ? '--cached' : null,
'--diff-filter=ACMRTUB',
revision,
].filter(Boolean)
)
].filter(Boolean),
),
),
...(staged
? []
: getLines(
runGit(directory, ['ls-files', '--others', '--exclude-standard'])
runGit(directory, ['ls-files', '--others', '--exclude-standard']),
)),
].filter(Boolean);
};
2 changes: 1 addition & 1 deletion src/scms/hg.js
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ export const getSinceRevision = (directory, { branch }) => {
export const getChangedFiles = (directory, revision) => {
return [
...getLines(
runHg(directory, ['status', '-n', '-a', '-m', '--rev', revision])
runHg(directory, ['status', '-n', '-a', '-m', '--rev', revision]),
),
].filter(Boolean);
};
Loading