Skip to content

Commit

Permalink
fix: replace inline trim in favor of Ramda version
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Aug 9, 2016
1 parent f8597ca commit 743479f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/gitinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import fs from 'fs';
import path from 'path';
import R from 'ramda';
import {
parseRemoteOriginUrl,
trim,
parseIni,
isGitDirectory,
findGitPath
Expand Down Expand Up @@ -129,7 +129,7 @@ export default (userConfig: TypeConfig = {}): Object => {
throw new Error('Cannot read the commit SHA of the current HEAD from the ' + shaFile + '.\n' + err);
}

return trim(sha);
return R.trim(sha);
};

/**
Expand Down
8 changes: 0 additions & 8 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,3 @@ export const findGitPath = (startPath: string): string => {

return gitpath;
};

/**
* @param value A string to be trimmed.
* @returns An initial string without leading and trailing spaces, tabs, newlines
*/
export const trim = (value: string): string => {
return value.replace(/^\s+|\s+$/g, '');
};
8 changes: 1 addition & 7 deletions tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
} from 'chai';
import {
findGitPath,
parseRemoteOriginUrl,
trim
parseRemoteOriginUrl
} from './../src/utils';

describe('utils', () => {
Expand Down Expand Up @@ -46,9 +45,4 @@ describe('utils', () => {
});
});
});
describe('trim()', () => {
it('trims whitespaces, tabs and newlines', () => {
expect(trim(' \tsomeText with spaces\n')).to.equal('someText with spaces');
});
});
});

0 comments on commit 743479f

Please sign in to comment.