Skip to content

Conversation

@damccorm
Copy link

Added samples for Git and Wiki. Probably could be developed more (in particular Git), but this is at least a good starting place.

samples/wiki.ts Outdated
const textStream: NodeJS.ReadableStream = await wikiApiObject.getPageText(project, wikiId)
console.log("Wiki text", textStream.read().toString());

if (wikis.length == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Length is 0 then we try to delete? Should be !==?

Copy link
Author

Choose a reason for hiding this comment

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

No, I think this is correct logic because we only want to delete a wiki if we created one (otherwise we're deleting their actual wiki), and we only want to create a wiki if they don't already have one (otherwise it will fail). With that said, the code clarity is not great, I've updated to hopefully be more clear

samples/wiki.ts Outdated

if (wikis.length == 0) {
common.heading("Delete the created wiki");
await wikiApiObject.deleteWiki(wikiId, project);
Copy link
Member

Choose a reason for hiding this comment

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

Check response if there is one and print it.

samples/wiki.ts Outdated
}

common.heading("Get the text from a wiki");
const textStream: NodeJS.ReadableStream = await wikiApiObject.getPageText(project, wikiId)
Copy link
Member

Choose a reason for hiding this comment

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

Rename variable to pageText

samples/wiki.ts Outdated

export async function run() {
let webApi: nodeApi.WebApi = await common.getWebApi();
let wikiApiObject: WikiApi.IWikiApi = await webApi.getWikiApi();
Copy link
Member

Choose a reason for hiding this comment

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

Const?

@damccorm damccorm self-assigned this Sep 19, 2018
@damccorm damccorm merged commit d759b18 into microsoft:master Sep 20, 2018
@damccorm damccorm deleted the add-samples branch September 20, 2018 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants