update scripts with upath

now using upath within build scripts for better compatibility
This commit is contained in:
David Miller 2021-03-29 19:45:48 -04:00
parent 0bcdad5961
commit 591ec679dd
11 changed files with 45 additions and 37 deletions

6
package-lock.json generated
View File

@ -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",

View File

@ -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"
}
}

View File

@ -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);

View File

@ -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}/*`)

View File

@ -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)
};

View File

@ -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);
}

View File

@ -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);
};

View File

@ -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);
}

View File

@ -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!');

View File

@ -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' },

View File

@ -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 scripts/sb-watch.js', name: 'SB_WATCH', prefixColor: 'bgBlue.bold' },