Skip to content
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

Initial Setup of fs-10 Objective #43

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion levels/tower_of_knowledge/level.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"fs-02-pwd",
"fs-03-ls",
"fs-04-cd",
"fs-05-mkdir"
"fs-05-mkdir",
"fs-10-drawer"
]
}
25 changes: 25 additions & 0 deletions levels/tower_of_knowledge/objectives/fs-10-drawer/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<% const isWindows = context.systemInfo.os === 'win32'; %>

# Creating a Cutlery Drawer Directory

<div class="aside">
<h3>Requirements</h3>
<ul>
<li>Step 1.</li>
<li>Step 2.</li>
<li>Step 3.</li>
<li>Once you're done, press <em>HACK</em>.</li>
</ul>
</div>

General content here...

<% if(isWindows) { %>

Windows specific content here...

<% } else { %>

\*nix specific content here...

<% } %>
16 changes: 16 additions & 0 deletions levels/tower_of_knowledge/objectives/fs-10-drawer/objective.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"title": "Creating a Cutlery Drawer Directory",
"description": "Create the cutlery drawer directory as described.",
"validation_fields": [
{
"name": "cutleryDrawerDirPath",
"type": "text",
"placeholder": "/path/to/cutlery/drawer/directory",
"label": "What is the path to the cutlery drawer directory you made?"
}
],
"show_ide": false,
"rewards": {
"xp": 100
}
}
44 changes: 44 additions & 0 deletions levels/tower_of_knowledge/objectives/fs-10-drawer/validator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { existsSync } = require("fs");

module.exports = async function (helper) {
const cutleryDrawerDirPath = helper.getNormalizedInput(
"cutleryDrawerDirPath",
{
lowerCase: false,
}
);

try {
if (!cutleryDrawerDirPath) {
helper.fail(
"You need to provide the path to your cutlery drawer directory in the Hack Interface!"
);
return;
}

if (!existsSync(cutleryDrawerDirPath)) {
helper.fail(
`TwilioQuest could not locate the cutlery drawer directory at the path you entered, "${cutleryDrawerDirPath}".`
);
return;
}

// TODO: Add checks for commands improperly followed, file system not created, partial path, case sensitivity,
// and separators once the predefined directory entries for this objective have been determined
} catch (err) {
helper.fail(`An error occurred while TwilioQuest was trying to validate your cutlery drawer directory.

${err}`);
return;
}

helper.success(
"Your cutlery drawer directory looks clean and organized. Great job!",
[
{
name: "DEV_FUNDAMENTALS_FILE_SYSTEM_CUTLERY_DRAWER_DIR",
value: cutleryDrawerDirPath,
},
]
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Walkthrough

Content here...