Skip to content

Commit

Permalink
feat: Removes --force-git option
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Use --git option instead to point to your .git directory
  • Loading branch information
saitho committed Mar 13, 2020
1 parent ea1d0e0 commit 3a74ee4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 28 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ With that setup the file is updated when `npm start` and `npm build` are run.
| Argument | Meaning | Default |
|---|---|---|
| --root | root directory where your package.json is located | . |
| --file | relative location of the output file (based on the root directory) | ./src/_version.ts |
| --force-git | force Git detection (deprecated, use --git instead to point to your .git directory) | false |
| --file | relative location of the output file (based on the root directory) | ./src/_version.ts | false |
| --git | relative location of the folder containing the .git folder (based on the root directory) | . |
| --pnpm | PNPM has a different folder structure, resulting in a different root level. Add this if you use PNPM to install your dependencies. If package.json is not found at the expected PNPM path, it will fall back to the default one. This setting is ignored if `--root` is an absolute path. | false |

Expand Down
12 changes: 1 addition & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ for (const location of projectLocations) {
}
}

// TODO: remove with v2
if (argv.hasOwnProperty('force-git')) {
console.log('[TsAppVersion] ' + colors.blue('Deprecation notice: ') + colors.red('The use of --force-git is will be removed with version 2. Use --git instead to point to the folder where the .git folder resides.'));
}

if (!projectFolder.length) {
console.log('[TsAppVersion] ' + colors.yellow('Cannot find package.json in root path. Skipping...'));
return;
Expand Down Expand Up @@ -90,12 +85,7 @@ if (argv.hasOwnProperty('git')) {
gitFolder = argv.git;
}
}
if (argv.hasOwnProperty('force-git')) {
// TODO: remove with v2
// this option is required e.g. when the repository in question is a sub repository
enableGit = true;
console.log('[TsAppVersion] Git repository forced. Getting current commit information.');
} else if (fs.existsSync(path.join(gitFolder, '.git'))) {
if (fs.existsSync(path.join(gitFolder, '.git'))) {
enableGit = true;
console.log('[TsAppVersion] Git repository detected. Getting current commit information.');
}
Expand Down
15 changes: 0 additions & 15 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,6 @@ describe('appversion', function() {
});
});

it('should throw deprecation message when using --force-git', function(done) {
exec('node index.js --force-git', (err, stdout, stderr) => {
if (err) {
done('Test failed: Could not execute command.');
return;
}
if (stderr) {
done(stderr);
return;
}
expect(stdout).to.contains('Deprecation notice');
done();
});
});

it('should succeed with default settings and without a Git repository', function(done) {
fs.mkdirSync(path.join(repoDir, 'src'), {recursive: true});
fs.writeFileSync(path.join(repoDir, 'package.json'), '{"version": "1.0.0"}');
Expand Down

0 comments on commit 3a74ee4

Please sign in to comment.