-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add system path check to start command #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, great work! Please address the feedback items I mentioned, then push up your changes, which will update the PR.
lib/commands/init.mjs
Outdated
@@ -3,6 +3,19 @@ import fs from 'fs'; | |||
import path from 'path'; | |||
import ejs from 'ejs'; | |||
import {getAbsolutePathFromRelativeToRoot} from "../utils/path_utils.mjs"; | |||
import {isSystemDirectory} from "../commands/pathdetect.mjs"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For filenames, we have a convention of separating words with underscores, so we probably want path_detect.mjs here.
lib/commands/init.mjs
Outdated
import {isSystemDirectory} from "../commands/pathdetect.mjs"; | ||
import { fileURLToPath } from 'url'; | ||
import { dirname } from 'path'; | ||
const __filename = fileURLToPath(import.meta.url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the variables are private because we are in a module, so no need to underscore them in the names.
lib/commands/init.mjs
Outdated
const __dirname = dirname(__filename); | ||
|
||
let isSDirectory = isSystemDirectory(__dirname); | ||
console.log(isSDirectory); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't want to keep this in the output, so we should clean that line up.
lib/commands/pathdetect.mjs
Outdated
dirPath = dirPath.toLowerCase().replace(/\\+/g, '/'); | ||
if (!dirPath.endsWith('/')) { | ||
dirPath += '/'; | ||
console.log(dirPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to be just debug output, or were you thinking this should stay in our output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Created a new file: lib/commands/pathdetect.mjs that contains a function to check if current working directory is a common system directory.
Edited lib/commands/init.mjs to print a warning to console if user is in current working dir, and exit with err code 1.