Skip to content
This repository has been archived by the owner on Nov 3, 2019. It is now read-only.

Commit

Permalink
fix(plugin-example): fix examples generation on Windows
Browse files Browse the repository at this point in the history
Use path normalization to make example generation work on Windows.
  • Loading branch information
zkochan committed Apr 3, 2016
1 parent 8653680 commit 2b7e4cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion plugins/mos-plugin-example/lib/hook-console-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = hookConsoleLog

const callsites = require('callsites')
const removeLastEOL = require('../../remove-last-eol')
const normalizePath = require('normalize-path')

const originalLog = console.log

Expand Down Expand Up @@ -38,7 +39,7 @@ function callsiteForFile (fileName) {

function trace () {
return callsites().map(callsite => ({
file: callsite.getFileName() || '?',
file: normalizePath(callsite.getFileName()) || '?',
line: callsite.getLineNumber(),
column: callsite.getColumnNumber(),
}))
Expand Down
5 changes: 3 additions & 2 deletions plugins/mos-plugin-example/lib/stdout-to-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ const fs = require('fs')
const spawn = require('cross-spawn-async')
const path = require('path')
const SourceMapConsumer = require('source-map').SourceMapConsumer
const hookPath = path.resolve(__dirname, './hook-console-log')
const normalizePath = require('normalize-path')
const hookPath = normalizePath(path.resolve(__dirname, './hook-console-log'))
const position = require('file-position')

function stdoutToComments (filePath) {
return new Promise((resolve, reject) => {
fs.readFile(filePath, 'utf8', (err, content) => {
if (err) return reject(err)

const tmpFileName = filePath + Math.random() + '.js'
const tmpFileName = normalizePath(filePath + Math.random() + '.js')
fs.writeFileSync(tmpFileName, addHook({
code: content,
filePath: tmpFileName,
Expand Down

0 comments on commit 2b7e4cf

Please sign in to comment.