@thisismanta/semantic-version 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,16 +28,21 @@ const fp = __importStar(require("path"));
28
28
  const execa_1 = require("execa");
29
29
  main();
30
30
  async function main() {
31
- let workingPath = process.cwd();
32
- if (fp.basename(fp.dirname(workingPath)) !== 'node_modules') {
31
+ const currentDirectoryPath = process.cwd();
32
+ console.log('Found', currentDirectoryPath);
33
+ if (fp.basename(fp.dirname(currentDirectoryPath)) !== 'node_modules') {
33
34
  console.log('Do nothing when running this on semantic-version repository.');
34
35
  return;
35
36
  }
36
- workingPath = fp.resolve(workingPath, '../..');
37
- const huskyDirectoryPath = fp.resolve(workingPath, '.husky');
37
+ console.log('Installing Husky');
38
38
  await (0, execa_1.execaCommand)('npx husky install');
39
+ // Up 3 levels because of `node_modules/@thisismanta/semantic-version`
40
+ const huskyDirectoryPath = fp.resolve(currentDirectoryPath, '../../..', '.husky');
41
+ await fs.access(huskyDirectoryPath);
42
+ console.log('Found', huskyDirectoryPath);
39
43
  await upsert(fp.join(huskyDirectoryPath, 'commit-msg'), 'npx lint-commit-message ${1}');
40
44
  await upsert(fp.join(huskyDirectoryPath, 'post-commit'), 'npx auto-npm-version');
45
+ console.log('Done adding Git hooks.');
41
46
  }
42
47
  async function upsert(filePath, text) {
43
48
  try {
@@ -54,6 +59,6 @@ async function upsert(filePath, text) {
54
59
  .findIndex(line => line.trim().includes(text));
55
60
  if (index === -1) {
56
61
  await fs.appendFile(filePath, '\n' + text + '\n', 'utf-8');
57
- console.log('Added', text, 'to', filePath);
62
+ console.log(`Added "${text}" to ${filePath}`);
58
63
  }
59
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisismanta/semantic-version",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "author": "Anantachai Saothong <thisismanta@gmail.com>",
5
5
  "license": "ISC",
6
6
  "engines": {