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-09 Objective #42

Draft
wants to merge 1 commit 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-09-cutlery"
]
}
25 changes: 25 additions & 0 deletions levels/tower_of_knowledge/objectives/fs-09-cutlery/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<% const isWindows = context.systemInfo.os === 'win32'; %>

# Creating Our Own Directories

<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

<% } else { %>

\*nix specific content

<% } %>
16 changes: 16 additions & 0 deletions levels/tower_of_knowledge/objectives/fs-09-cutlery/objective.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"title": "Finding the fork",
"description": "Given a directory tree representing a file system, find the path to the fork.",
"validation_fields": [
{
"name": "filePath",
"type": "text",
"placeholder": "/path/to/file",
"label": "What is the path to the \"fork\" file?"
}
],
"show_ide": false,
"rewards": {
"xp": 100
}
}
35 changes: 35 additions & 0 deletions levels/tower_of_knowledge/objectives/fs-09-cutlery/validator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { existsSync } = require("fs");

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

try {
if (!filePath) {
helper.fail(
'You need to provide the path to the "fork" file in the Hack Interface!'
);
return;
}

if (!existsSync(filePath)) {
helper.fail(
`TwilioQuest could not find the "fork" file at the path you entered, "${newDirPath}".`
);
return;
}

// TODO: add checks for partial path, case sensitivity, and separators once the predefined path for this objective
// has been determined
} catch (err) {
helper.fail(`An error occurred while TwilioQuest was trying to validate the path to gave to the "fork" file.

${err}`);
return;
}

helper.success(
'TwiloQuest was able to find the "fork" file at the path you provided! Good job!'
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Walkthrough

Content here...