ngx-devkit-builders 0.0.5 → 0.0.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/version/index.js +18 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-devkit-builders",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "author": {
5
5
  "name": "Dominik Hladík",
6
6
  "email": "dominik.hladik@seznam.cz",
package/version/index.js CHANGED
@@ -38,30 +38,26 @@ exports.default = (0, architect_1.createBuilder)(({ outputFile, fields, lint, va
38
38
  success: false
39
39
  };
40
40
  }
41
- let head = (0, fs_1.readFileSync)(headFile, encoding).toString().trim();
42
- if (head.split(':').length > 1) {
43
- head = head.split(':')[1].trim();
41
+ let commit = (0, fs_1.readFileSync)(headFile).toString().trim();
42
+ let branch = '';
43
+ if (commit.indexOf(':') !== -1) {
44
+ branch = commit.substring(5);
45
+ const refFile = `${rootPath}/.git/${commit.substring(5)}`;
46
+ if (verbose === true)
47
+ ctx.logger.info(`Last commit is located here ${refFile}`);
48
+ if (!(0, fs_1.existsSync)(refFile)) {
49
+ ctx.logger.info(generalError);
50
+ ctx.logger.error(`${refFile} was not found`);
51
+ return {
52
+ success: false
53
+ };
54
+ }
55
+ commit = (0, fs_1.readFileSync)(refFile).toString().trim();
44
56
  }
45
- if (verbose === true)
46
- ctx.logger.info(`Head is ${head}`);
47
- const refFile = `${rootPath}/.git/${head}`;
48
- if (verbose === true)
49
- ctx.logger.info(`Last commit is located here ${refFile}`);
50
- if (!(0, fs_1.existsSync)(refFile)) {
51
- ctx.logger.info(generalError);
52
- ctx.logger.error(`${refFile} was not found`);
53
- return {
54
- success: false
55
- };
57
+ else {
58
+ branch = commit;
56
59
  }
57
- const commit = head ? (0, fs_1.readFileSync)(refFile, encoding).toString().trim() : undefined;
58
- if (verbose === true)
59
- ctx.logger.info(`Commit is ${commit}`);
60
- const branch = head?.split('/')?.pop();
61
- if (verbose === true)
62
- ctx.logger.info(`Branch is ${branch}`);
63
- const git = branch || commit ? { branch, commit } : undefined;
64
- result.git = git;
60
+ result.git = branch || commit ? { branch: branch.replace(/^refs\/heads\//, ''), commit } : undefined;
65
61
  }
66
62
  const json = JSON.stringify(result, null, 2);
67
63
  const rawFormat = outputFile?.split('.')?.pop();