@contrast/core 1.29.0 → 1.30.0

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/lib/app-info.js +6 -7
  2. package/package.json +2 -2
package/lib/app-info.js CHANGED
@@ -40,8 +40,8 @@ module.exports = function (core) {
40
40
 
41
41
  try {
42
42
  cmd = getCommand();
43
+ pkgInfo = getPackageInfo();
43
44
  entrypoint = getEntrypoint();
44
- pkgInfo = getPackageInfo(entrypoint);
45
45
  } catch (_err) {
46
46
  err = _err;
47
47
  }
@@ -115,13 +115,14 @@ module.exports = function (core) {
115
115
  */
116
116
  function getEntrypoint() {
117
117
  let entrypoint = process.argv[1];
118
+ const { packageData } = pkgInfo;
118
119
 
119
120
  try {
120
121
  if (entrypoint && fs.statSync(entrypoint).isDirectory()) {
121
- const indexJs = path.join(entrypoint, './index.js');
122
+ const main = path.join(entrypoint, packageData.main || 'index.js');
122
123
  try {
123
- if (fs.statSync(indexJs)) {
124
- entrypoint = indexJs;
124
+ if (fs.statSync(main)) {
125
+ entrypoint = main;
125
126
  }
126
127
  } catch (err) {
127
128
  entrypoint = null;
@@ -157,7 +158,7 @@ module.exports = function (core) {
157
158
  * @returns {PackageInfo} dir, packageData, and packageFile
158
159
  * @throws {Error} if package can't be found or parsed
159
160
  */
160
- function getPackageInfo(entrypoint) {
161
+ function getPackageInfo() {
161
162
  const cwd = process.cwd();
162
163
  const dirs = new Set();
163
164
 
@@ -170,7 +171,6 @@ module.exports = function (core) {
170
171
  dirs.add(path.resolve(app_root));
171
172
  } else {
172
173
  // otherwise check up folder tree from entrypoint and then cwd
173
- dirs.add(path.dirname(entrypoint));
174
174
  dirs.add(cwd);
175
175
  }
176
176
 
@@ -186,7 +186,6 @@ module.exports = function (core) {
186
186
  const message = 'unable to locate application package.json';
187
187
  logger.error({
188
188
  app_root,
189
- entrypoint,
190
189
  paths: Array.from(dirs),
191
190
  }, message);
192
191
  throw new Error(message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/core",
3
- "version": "1.29.0",
3
+ "version": "1.30.0",
4
4
  "description": "Preconfigured Contrast agent core services and models",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -16,7 +16,7 @@
16
16
  "test": "../scripts/test.sh"
17
17
  },
18
18
  "dependencies": {
19
- "@contrast/common": "1.18.0",
19
+ "@contrast/common": "1.19.0",
20
20
  "@contrast/find-package-json": "^1.0.0",
21
21
  "@contrast/fn-inspect": "^4.0.0"
22
22
  }