Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  windows fix
  • Loading branch information
berkandirim committed Oct 31, 2018
2 parents cc117d9 + df976e2 commit 97b354d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/server/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const pageData = {};
const getPage = (fileData) => {
if (fileData.dir !== sharedContent) {
const fileDir = fileData.dir.split(output);
const href = fileDir[fileDir.length - 1];
const fileName = fileData.dir.split('/');
const href = process.platform === 'win32' ? fileDir[fileDir.length - 1].replace(/\\/g, '/') : fileDir[fileDir.length - 1];
const fileName = process.platform === 'win32' ? fileData.dir.split('\\') : fileData.dir.split('/');
const pageName = fileName[fileName.length - 1].replace(/-/g, ' ');

const programName = fileName[2] ? fileName[2].replace(/-/g, ' ') : '';
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function _eval(file) {
if (file) {
const stream = [
'import React from \'react\';',
`import Component from '${ path.join(process.cwd(), file) }';`
`import Component from '${ process.platform === 'win32' ? path.join(process.cwd(), file).replace(/\\/g, '\\\\') : path.join(process.cwd(), file) }';`
];

if (file.includes('/block-')) {
Expand Down
8 changes: 4 additions & 4 deletions src/tasks/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ const { config: { output, source, assets }, createCliArgs } = require('../utils'

const watch = (linting) => {
const exec = [
'./node_modules/.bin/htmplar build',
'./node_modules/.bin/htmplar serve'
'node ./node_modules/htmplar/src/cli/index.js build',
'node ./node_modules/htmplar/src/cli/index.js serve'
];

if (typeof linting !== 'undefined' &&
((linting === true || Array.isArray(linting)) && linting[0] === true)) {
const lintingArgs = Array.isArray(linting) ? createCliArgs(linting[1]) : '';

exec.unshift(`./node_modules/.bin/htmplar lint ${ lintingArgs }`);
exec.unshift(`node ./node_modules/htmplar/src/cli/index.js lint ${ lintingArgs }`);
}

nodemon({
exec: `node ${ exec.join(' && ') }`,
exec: `${ exec.join(' && ') }`,
watch: [ path.join(process.cwd(), source), path.join(process.cwd(), output), path.join(process.cwd(), assets) ],
ext: 'js, jsx, mjs, json, css, scss'
});
Expand Down
3 changes: 2 additions & 1 deletion src/utils/walker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const { exclude } = require('./config');

const walkSync = (dir, filelist = []) => {
let _filelist = filelist;
const dirPath = process.platform === 'win32' ? dir.replace(/\\/g, '/') : dir;

if (exclude.length <= 0 || !exclude.includes(dir)) {
if (exclude.length <= 0 || !exclude.includes(dirPath)) {
fs.readdirSync(dir).forEach((file) => {
_filelist = fs.statSync(path.join(dir, file)).isDirectory()
? walkSync(path.join(dir, file), _filelist)
Expand Down

0 comments on commit 97b354d

Please sign in to comment.