This repository was archived by the owner on Apr 13, 2020. It is now read-only.
  
  
  - 
                Notifications
    
You must be signed in to change notification settings  - Fork 16
 
[HOUSEKEEPING] Finding broken links in md files and fix them #432
          
     Merged
      
      
    
  
     Merged
                    Changes from 9 commits
      Commits
    
    
            Show all changes
          
          
            11 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      98bc86a
              
                [HOUSEKEEPING] Finding broken links in md files and fix them
              
              
                dennisseah 5a5ac78
              
                Merge branch 'master' into brokenLinks
              
              
                dennisseah 2abd364
              
                Merge branch 'master' into brokenLinks
              
              
                dennisseah 2b34be7
              
                Merge branch 'master' into brokenLinks
              
              
                dennisseah 6621cd9
              
                using  markdown-link-check
              
              
                dennisseah 942bd60
              
                Merge branch 'brokenLinks' of https://github.com/CatalystCode/spk int…
              
              
                dennisseah 521d895
              
                update md-lint
              
              
                dennisseah 717004b
              
                Update azure-pipelines.yml
              
              
                dennisseah 036d15d
              
                Merge branch 'master' into brokenLinks
              
              
                dennisseah dd82f23
              
                Merge branch 'master' into brokenLinks
              
              
                yradsmikham 8fc4dc3
              
                script is not needed because we do not support windows runtime
              
              
                dennisseah File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import fs from "fs"; | ||
| import path from "path"; | ||
| import { exec } from "../src/lib/shell"; | ||
| 
     | 
||
| // get sub folders under commands folder. | ||
| const getMarkdownFiles = (curDir: string, mds: string[]): void => { | ||
| fs.readdirSync(curDir).forEach((f) => { | ||
| const p = path.join(curDir, f); | ||
| if (fs.lstatSync(p).isDirectory()) { | ||
| getMarkdownFiles(p, mds); | ||
| } else if (p.endsWith(".md")) { | ||
| mds.push(p); | ||
| } | ||
| }); | ||
| }; | ||
| 
     | 
||
| const testMd = async (f: string): Promise<void> => { | ||
| try { | ||
| await exec("./node_modules/.bin/markdown-link-check", [f]); | ||
| } catch (e) { | ||
| console.log(`${f}: ${e.message}`); | ||
| process.exit(1); | ||
| } | ||
| }; | ||
| 
     | 
||
| (async (): Promise<void> => { | ||
| const dir = path.join(process.cwd(), "guides"); | ||
| const mdFiles: string[] = []; | ||
| getMarkdownFiles(dir, mdFiles); | ||
| const promises: Promise<void>[] = []; | ||
| 
     | 
||
| mdFiles.forEach((f) => { | ||
| promises.push(testMd(f)); | ||
| }); | ||
| 
     | 
||
| await Promise.all(promises); | ||
| process.exit(0); | ||
| })(); | ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.
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 this script file may be un-necessary:
See: https://github.com/tcort/markdown-link-check#check-links-from-a-local-markdown-folder-recursive
You can inline this into a package.json script instead of calling this custom script
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 cannot because i need a status code 1 to stop the script. :-)
the inline approach always return 0
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.
Sorry Dennis, not quite sure I understand what you're saying. Npm scripts will exit with 1 if if any of the commands fail:
npm run i-will-fail # will exit with code 1are you thinking othewise?
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.
maybe you can try it yourself and let me know what you get
add this to your package.json
or just ran (at the root of spk repo)
then
there are errors reported by the tool and it is returning 0 status code.
Uh oh!
There was an error while loading. Please reload this page.
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.
@dennisseah try the suggestion here: tcort/markdown-link-check#57 (comment)
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.
@bnookala
and what about people using windows?
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.
@dennisseah this isn't a run-time requirement - just a development requirement. I expect that developers who are running windows who also want to contribute to spk development should do their work in a WSL environment.
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.
ok then. We do not support windows runtime.