diff --git a/package-lock.json b/package-lock.json index 5f39423..99d60c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2268,6 +2268,12 @@ "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", "dev": true }, + "upath": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/upath/-/upath-2.0.1.tgz", + "integrity": "sha512-1uEe95xksV1O0CYKXo8vQvN1JEbtJp7lb7C5U9HMsIp6IVwntkH/oNUzyVNQSd4S1sYk2FpSSW44FqMc8qee5w==", + "dev": true + }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", diff --git a/package.json b/package.json index d0a98a8..46f9ddf 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "prettier": "2.2.1", "pug": "3.0.2", "sass": "1.32.8", - "shelljs": "0.8.4" + "shelljs": "0.8.4", + "upath": "2.0.1" } } diff --git a/scripts/build-pug.js b/scripts/build-pug.js index 61cf6a5..47d036a 100644 --- a/scripts/build-pug.js +++ b/scripts/build-pug.js @@ -1,9 +1,9 @@ 'use strict'; -const path = require('path'); +const upath = require('upath'); const sh = require('shelljs'); const renderPug = require('./render-pug'); -const srcPath = path.resolve(path.dirname(__filename), '../src'); +const srcPath = upath.resolve(upath.dirname(__filename), '../src'); sh.find(srcPath).forEach(_processFile); diff --git a/scripts/clean.js b/scripts/clean.js index 8bbc244..75cfa97 100644 --- a/scripts/clean.js +++ b/scripts/clean.js @@ -1,7 +1,7 @@ const sh = require('shelljs'); -const path = require('path'); +const upath = require('upath'); -const destPath = path.resolve(path.dirname(__filename), '../dist'); +const destPath = upath.resolve(upath.dirname(__filename), '../dist'); sh.rm('-rf', `${destPath}/*`) diff --git a/scripts/render-assets.js b/scripts/render-assets.js index 4f3fb75..9139f9d 100644 --- a/scripts/render-assets.js +++ b/scripts/render-assets.js @@ -1,11 +1,11 @@ 'use strict'; const fs = require('fs'); -const path = require('path'); +const upath = require('upath'); const sh = require('shelljs'); module.exports = function renderAssets() { - const sourcePath = path.resolve(path.dirname(__filename), '../src/assets'); - const destPath = path.resolve(path.dirname(__filename), '../dist/.'); + const sourcePath = upath.resolve(upath.dirname(__filename), '../src/assets'); + const destPath = upath.resolve(upath.dirname(__filename), '../dist/.'); sh.cp('-R', sourcePath, destPath) }; \ No newline at end of file diff --git a/scripts/render-pug.js b/scripts/render-pug.js index 899ac22..e22f448 100644 --- a/scripts/render-pug.js +++ b/scripts/render-pug.js @@ -1,13 +1,13 @@ 'use strict'; const fs = require('fs'); -const path = require('path'); +const upath = require('upath'); const pug = require('pug'); const sh = require('shelljs'); const prettier = require('prettier'); module.exports = function renderPug(filePath) { const destPath = filePath.replace(/src\/pug\//, 'dist/').replace(/\.pug$/, '.html'); - const srcPath = path.resolve(path.dirname(__filename), '../src'); + const srcPath = upath.resolve(upath.dirname(__filename), '../src'); console.log(`### INFO: Rendering ${filePath} to ${destPath}`); const html = pug.renderFile(filePath, { @@ -16,7 +16,7 @@ module.exports = function renderPug(filePath) { basedir: srcPath }); - const destPathDirname = path.dirname(destPath); + const destPathDirname = upath.dirname(destPath); if (!sh.test('-e', destPathDirname)) { sh.mkdir('-p', destPathDirname); } @@ -32,4 +32,4 @@ module.exports = function renderPug(filePath) { }); fs.writeFileSync(destPath, prettified); -}; \ No newline at end of file +}; diff --git a/scripts/render-scripts.js b/scripts/render-scripts.js index 2e23816..245ebac 100644 --- a/scripts/render-scripts.js +++ b/scripts/render-scripts.js @@ -1,12 +1,18 @@ 'use strict'; const fs = require('fs'); const packageJSON = require('../package.json'); -const path = require('path'); +const upath = require('upath'); const sh = require('shelljs'); module.exports = function renderScripts() { - const sourcePath = path.resolve(path.dirname(__filename), '../src/js/scripts.js'); - const destPath = path.resolve(path.dirname(__filename), '../dist/js/scripts.js'); + + const sourcePath = upath.resolve(upath.dirname(__filename), '../src/js'); + const destPath = upath.resolve(upath.dirname(__filename), '../dist/.'); + + sh.cp('-R', sourcePath, destPath) + + const sourcePathScriptsJS = upath.resolve(upath.dirname(__filename), '../src/js/scripts.js'); + const destPathScriptsJS = upath.resolve(upath.dirname(__filename), '../dist/js/scripts.js'); const copyright = `/*! * Start Bootstrap - ${packageJSON.title} v${packageJSON.version} (${packageJSON.homepage}) @@ -14,12 +20,7 @@ module.exports = function renderScripts() { * Licensed under ${packageJSON.license} (https://github.com/StartBootstrap/${packageJSON.name}/blob/master/LICENSE) */ ` - const scriptsJS = fs.readFileSync(sourcePath); - const destPathDirname = path.dirname(destPath); + const scriptsJS = fs.readFileSync(sourcePathScriptsJS); - if (!sh.test('-e', destPathDirname)) { - sh.mkdir('-p', destPathDirname); - } - - fs.writeFileSync(destPath, copyright + scriptsJS); + fs.writeFileSync(destPathScriptsJS, copyright + scriptsJS); }; \ No newline at end of file diff --git a/scripts/render-scss.js b/scripts/render-scss.js index 3c242cb..eb03da6 100644 --- a/scripts/render-scss.js +++ b/scripts/render-scss.js @@ -2,24 +2,24 @@ const autoprefixer = require('autoprefixer') const fs = require('fs'); const packageJSON = require('../package.json'); -const path = require('path'); +const upath = require('upath'); const postcss = require('postcss') const sass = require('sass'); const sh = require('shelljs'); const stylesPath = '../src/scss/styles.scss'; -const destPath = path.resolve(path.dirname(__filename), '../dist/css/styles.css'); +const destPath = upath.resolve(upath.dirname(__filename), '../dist/css/styles.css'); module.exports = function renderSCSS() { const results = sass.renderSync({ data: entryPoint, includePaths: [ - path.resolve(path.dirname(__filename), '../node_modules') + upath.resolve(upath.dirname(__filename), '../node_modules') ], }); - const destPathDirname = path.dirname(destPath); + const destPathDirname = upath.dirname(destPath); if (!sh.test('-e', destPathDirname)) { sh.mkdir('-p', destPathDirname); } diff --git a/scripts/sb-watch.js b/scripts/sb-watch.js index 27d4c8a..572b309 100644 --- a/scripts/sb-watch.js +++ b/scripts/sb-watch.js @@ -2,7 +2,7 @@ const _ = require('lodash'); const chokidar = require('chokidar'); -const path = require('path'); +const upath = require('upath'); const renderAssets = require('./render-assets'); const renderPug = require('./render-pug'); const renderScripts = require('./render-scripts'); @@ -18,8 +18,8 @@ process.title = 'pug-watch'; process.stdout.write('Loading'); let allPugFiles = {}; -watcher.on('add', filePath => _processFile(filePath, 'add')); -watcher.on('change', filePath => _processFile(filePath, 'change')); +watcher.on('add', filePath => _processFile(upath.normalize(filePath), 'add')); +watcher.on('change', filePath => _processFile(upath.normalize(filePath), 'change')); watcher.on('ready', () => { READY = true; console.log(' READY TO ROLL!'); diff --git a/scripts/start-debug.js b/scripts/start-debug.js index c796b27..a266e4c 100644 --- a/scripts/start-debug.js +++ b/scripts/start-debug.js @@ -1,7 +1,7 @@ const concurrently = require('concurrently'); -const path = require('path'); +const upath = require('upath'); -const browserSyncPath = path.resolve(path.dirname(__filename), '../node_modules/.bin/browser-sync'); +const browserSyncPath = upath.resolve(upath.dirname(__filename), '../node_modules/.bin/browser-sync'); concurrently([ { command: 'node --inspect scripts/sb-watch.js', name: 'SB_WATCH', prefixColor: 'bgBlue.bold' }, diff --git a/scripts/start.js b/scripts/start.js index b2e5cee..3d6abe2 100644 --- a/scripts/start.js +++ b/scripts/start.js @@ -1,13 +1,13 @@ const concurrently = require('concurrently'); -const path = require('path'); +const upath = require('upath'); -const browserSyncPath = path.resolve(path.dirname(__filename), '../node_modules/.bin/browser-sync'); +const browserSyncPath = upath.resolve(upath.dirname(__filename), '../node_modules/.bin/browser-sync'); concurrently([ { command: 'node scripts/sb-watch.js', name: 'SB_WATCH', prefixColor: 'bgBlue.bold' }, - { + { command: `"${browserSyncPath}" --reload-delay 2000 --reload-debounce 2000 dist -w --no-online`, - name: 'SB_BROWSER_SYNC', + name: 'SB_BROWSER_SYNC', prefixColor: 'bgGreen.bold', } ], { @@ -16,9 +16,9 @@ concurrently([ }).then(success, failure); function success() { - console.log('Success'); + console.log('Success'); } function failure() { console.log('Failure'); -} +} \ No newline at end of file