-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bb329c
commit 9267f1b
Showing
3 changed files
with
125 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const { execSync } = require('child_process'); | ||
const path = require('path'); | ||
const { logger } = require('@hubspot/local-dev-lib/logger'); | ||
const { fetchProject } = require('@hubspot/local-dev-lib/api/projects'); | ||
const { getAccountId } = require('./commonOpts'); | ||
|
||
class DoctorManager { | ||
constructor() { | ||
this.accountId = getAccountId(); | ||
} | ||
|
||
getNpmVersion() { | ||
try { | ||
return execSync('npm --version') | ||
.toString() | ||
.trim(); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
|
||
shouldIncludeFile(file) { | ||
try { | ||
const ignoredDirs = ['node_modules']; | ||
for (const ignoredDir of ignoredDirs) { | ||
if (path.dirname(file).includes(path.join(path.sep, ignoredDir))) { | ||
return false; | ||
} | ||
} | ||
} catch (e) { | ||
logger.debug(e); | ||
} | ||
return true; | ||
} | ||
async fetchProjectDetails(accountId, projectConfig) { | ||
let projectDetails; | ||
try { | ||
projectDetails = await fetchProject( | ||
accountId, | ||
projectConfig.projectConfig.name | ||
); | ||
delete projectDetails.deployedBuild; | ||
delete projectDetails.latestBuild; | ||
delete projectDetails.portalId; | ||
} catch (e) { | ||
logger.debug(e); | ||
} | ||
return projectDetails; | ||
} | ||
} | ||
|
||
module.exports = DoctorManager; |