Skip to content

Commit

Permalink
Merge pull request #89 from UofGAnalytics/change-path-separator-behav…
Browse files Browse the repository at this point in the history
…iour

change path separator for windows anaconda
  • Loading branch information
dmca-glasgow committed Apr 13, 2022
2 parents c565321 + 64fe60e commit 1ecfcfd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@mapbox/remark-lint-link-text": "^0.6.0",
"base64-arraybuffer": "^1.0.2",
"chalk": "^5.0.0",
"dictionary-en-gb": "^2.3.0",
"dictionary-en-gb": "^2.4.0",
"escape-latex": "^1.2.0",
"figures": "^4.0.0",
"hash-sum": "^2.0.0",
Expand Down
10 changes: 6 additions & 4 deletions compiler/src/knitr/knitr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ async function createParentFile(unit: Unit, ctx: Context) {
// escape backslash path on windows
const formattedPath = path
.relative(ctx.cacheDir, filePath)
.replace(/\\/g, '\\\\');
.replace(/\\/g, '/');

const childCodeBlock = `\`\`\`{r, child='${formattedPath}'}${EOL}\`\`\``;
return acc + directive + EOL + EOL + childCodeBlock + EOL + EOL;
}, '');

console.log(value);

file.value = value;
return file;
}
Expand Down Expand Up @@ -100,10 +102,10 @@ function createKnitrCommand(
) {
const rFileDir = getKnitrFileDir();
const rFile = path.join(rFileDir, 'knitr.R');
const baseDir = path.parse(unitPath).dir;
const baseDir = path.parse(unitPath).dir + path.sep;
const cachedFile = path.join(ctx.cacheDir, `${uniqueId}.Rmd`);
const cacheDir = path.join(ctx.cacheDir, uniqueId);
return `Rscript "${rFile}" "${cachedFile}" "${baseDir}/" "${cacheDir}/"`;
const cacheDir = path.join(ctx.cacheDir, uniqueId) + path.sep;
return `Rscript "${rFile}" "${cachedFile}" "${baseDir}" "${cacheDir}"`;
}

function getKnitrFileDir() {
Expand Down
1 change: 0 additions & 1 deletion compiler/src/linter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import lintAltText from '@double-great/remark-lint-alt-text';
// @ts-expect-error
import lintLinkText from '@mapbox/remark-lint-link-text';
// @ts-expect-error
import dictionary from 'dictionary-en-gb';
import remark2retext from 'remark-retext';
import english from 'retext-english';
Expand Down
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ecfcfd

Please sign in to comment.