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

Fetch readme #208

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"eject": "craco eject",
"deploy": "dfx deploy",
"clean": "dfx stop && dfx start --clean --background",
"prestart": "dfx start --background; [ -f .dfx/local/canister_ids.json ] || dfx deploy",
"prestart": "dfx start --background --clean; [ -f .dfx/local/canister_ids.json ] || dfx deploy",
"predeploy": "npm run prestart",
"prepare": "husky install",
"postinstall": "mops install"
Expand Down
7 changes: 6 additions & 1 deletion src/components/ImportGithub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ export function ImportGitHub({ importCode, close, isPackageModal = false }) {
const [name, setName] = useState("");
const worker = useContext(WorkerContext);
const dispatch = useContext(WorkplaceDispatchContext);
const readmeUrl = `https://raw.githubusercontent.com/${repo}/${branch}/README.md`;
async function fetchCode() {
const files = await worker.fetchGithub({ repo, branch, dir });
let files = await worker.fetchGithub({ repo, branch, dir });
const readme = await (await fetch(readmeUrl)).text();
Copy link
Contributor

@rvanasa rvanasa Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to have unexpected behavior when README.md doesn't exist at the root of the repository. I opened another PR (#209) which implements this feature using a slightly different approach to account for this situation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

if (readme) {
files = { ...files, README: readme };
}
if (files) {
setError("");
importCode(files);
Expand Down
Loading