Skip to content

Commit

Permalink
Bulk Windows fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Octomerger authored Oct 9, 2020
2 parents 43832fd + d671034 commit 67021f3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
run: npm run check-deps

test:
if: github.repository == 'github/docs-internal'
runs-on: windows-latest
strategy:
fail-fast: false
Expand Down
7 changes: 4 additions & 3 deletions lib/all-products.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require('fs')
const path = require('path')
const slash = require('slash')
const assert = require('assert')
const { difference } = require('lodash')
const yaml = require('js-yaml')
Expand All @@ -23,11 +24,11 @@ const internalProducts = {}

sortedProductIds.forEach(productId => {
const relPath = productId
const dir = path.join('content', relPath)
const toc = path.join(dir, 'index.md')
const dir = slash(path.join('content', relPath))
const toc = slash(path.join(dir, 'index.md'))
const { data } = frontmatter(fs.readFileSync(toc, 'utf8'))
const applicableVersions = getApplicableVersions(data.versions, toc)
const href = path.join('/', applicableVersions[0], productId)
const href = slash(path.join('/', applicableVersions[0], productId))

internalProducts[productId] = {
id: productId,
Expand Down
3 changes: 2 additions & 1 deletion lib/redirects/precompile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path')
const slash = require('slash')
const patterns = require('../patterns')
const { latest } = require('../enterprise-server-releases')
const getOldPathsFromPermalink = require('../redirects/get-old-paths-from-permalink')
Expand Down Expand Up @@ -85,7 +86,7 @@ module.exports = async function precompileRedirects (pages) {
// add a veriation like `/free-pro-team@latest/v3/gists/comments`;
// again, we need to do this because all links in content get rewritten
if (!developerRoute.startsWith('/enterprise/')) {
const developerRouteWithVersion = path.join(nonEnterpriseDefaultVersion, developerRoute)
const developerRouteWithVersion = slash(path.join(nonEnterpriseDefaultVersion, developerRoute))
const developerRouteWithVersionAndLanguage = `/en/${developerRouteWithVersion}`
allRedirects[developerRouteWithVersion] = newPath
allRedirects[developerRouteWithVersionAndLanguage] = newPath
Expand Down
5 changes: 3 additions & 2 deletions middleware/archived-enterprise-versions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path')
const slash = require('slash')
const { latest, deprecated, firstVersionDeprecatedOnNewSite, lastVersionWithoutStubbedRedirectFiles } = require('../lib/enterprise-server-releases')
const patterns = require('../lib/patterns')
const versionSatisfiesRange = require('../lib/version-satisfies-range')
Expand Down Expand Up @@ -69,7 +70,7 @@ module.exports = async (req, res, next) => {
// for <2.13: /2.12/user/articles/viewing-contributions-on-your-profile
function getProxyPath (reqPath, requestedVersion) {
const proxyPath = versionSatisfiesRange(requestedVersion, `>=${firstVersionDeprecatedOnNewSite}`)
? path.join('/', requestedVersion, reqPath)
? slash(path.join('/', requestedVersion, reqPath))
: reqPath.replace(/^\/enterprise/, '')

return `https://github.github.com/help-docs-archived-enterprise-versions${proxyPath}`
Expand Down Expand Up @@ -97,7 +98,7 @@ function getFallbackRedirects (req, requestedVersion) {
// ]
.filter(oldPath => oldPath.startsWith('/enterprise') && patterns.enterpriseNoVersion.test(oldPath))
// add in the current language and version
.map(oldPath => path.join('/', req.context.currentLanguage, oldPath.replace('/enterprise/', `/enterprise/${requestedVersion}/`)))
.map(oldPath => slash(path.join('/', req.context.currentLanguage, oldPath.replace('/enterprise/', `/enterprise/${requestedVersion}/`))))
// ignore paths that match the requested path
.filter(oldPath => oldPath !== req.path)
}
5 changes: 3 additions & 2 deletions tests/content/lint-files.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path')
const slash = require('slash')
const fs = require('fs')
const walk = require('walk-sync')
const matter = require('@github-docs/frontmatter')
Expand Down Expand Up @@ -109,11 +110,11 @@ describe('lint-files', () => {
}

const contentMarkdownAbsPaths = walk(contentDir, mdWalkOptions).sort()
const contentMarkdownRelPaths = contentMarkdownAbsPaths.map(p => path.relative(rootDir, p))
const contentMarkdownRelPaths = contentMarkdownAbsPaths.map(p => slash(path.relative(rootDir, p)))
const contentMarkdownTuples = zip(contentMarkdownRelPaths, contentMarkdownAbsPaths)

const reusableMarkdownAbsPaths = walk(reusablesDir, mdWalkOptions).sort()
const reusableMarkdownRelPaths = reusableMarkdownAbsPaths.map(p => path.relative(rootDir, p))
const reusableMarkdownRelPaths = reusableMarkdownAbsPaths.map(p => slash(path.relative(rootDir, p)))
const reusableMarkdownTuples = zip(reusableMarkdownRelPaths, reusableMarkdownAbsPaths)

describe.each([...contentMarkdownTuples, ...reusableMarkdownTuples])(
Expand Down

0 comments on commit 67021f3

Please sign in to comment.