@jamesblanksby/toolkit 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # 🧰 Toolkit
1
+ # 🧰 toolkit
2
2
 
3
3
  > A customizable task automation tool.
4
4
 
@@ -4,11 +4,11 @@ import url from 'url';
4
4
  import { ESLint } from 'eslint';
5
5
  import uglifyjs from 'uglify-js';
6
6
 
7
- import { MemoryFile } from './../src/file.js';
7
+ import { MemoryFile } from '../src/file.js';
8
8
 
9
9
  const { PWD, } = process.env;
10
10
 
11
- async function scriptLint(files) {
11
+ async function jsLint(files) {
12
12
  const configDir = path.dirname(url.fileURLToPath(import.meta.url));
13
13
 
14
14
  const eslint = new ESLint({
@@ -35,7 +35,7 @@ async function scriptLint(files) {
35
35
  console.log(result);
36
36
  }
37
37
 
38
- async function* scriptMinify(files) {
38
+ async function* jsMinify(files) {
39
39
  for await (let file of files) {
40
40
  file = await file.read();
41
41
 
@@ -52,6 +52,6 @@ async function* scriptMinify(files) {
52
52
  }
53
53
 
54
54
  export {
55
- scriptLint,
56
- scriptMinify,
55
+ jsLint,
56
+ jsMinify,
57
57
  };
package/build/sass.js CHANGED
@@ -47,18 +47,20 @@ async function createCssAndMapFile(css, map, source) {
47
47
  }
48
48
 
49
49
  export default async function* sassCompile(files) {
50
+ const modulesDir = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), './../../..');
51
+
52
+ const options = {
53
+ loadPaths: [modulesDir,],
54
+ sourceMap: true,
55
+ };
56
+
50
57
  for await (const file of files) {
51
58
  const sassPaths = await findMainPaths(file.path);
52
59
 
53
- const modulesDir = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), './../../..');
54
-
55
60
  for (const sassPath of sassPaths) {
56
61
  let result;
57
62
  try {
58
- result = sass.compile(sassPath, {
59
- loadPaths: [modulesDir,],
60
- sourceMap: true,
61
- });
63
+ result = sass.compile(sassPath, options);
62
64
  } catch (error) {
63
65
  throw new Error(error.message);
64
66
  }
package/build/shopify.js CHANGED
@@ -24,8 +24,12 @@ function flattenCss(file) {
24
24
 
25
25
  const result = file.contents
26
26
  .replace(new RegExp('../(font|gfx)/', 'g'), '')
27
- .replace(new RegExp('url\\((.*?)\\)', 'g'), (_, match) => {
28
- const resource = match.replace(new RegExp('/', 'g'), '_');
27
+ .replace(new RegExp('url\\([\'"]?(.*?)?[\'"]?\\)', 'g'), (_, match) => {
28
+ if (/^https?:\/\//.test(match)) {
29
+ return `url("${match}")`;
30
+ }
31
+
32
+ const resource = match.replace(/\//g, '_');
29
33
  return `url({{ '${resource}' | asset_url }})`;
30
34
  });
31
35
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamesblanksby/toolkit",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
package/toolkit.config.js CHANGED
@@ -3,7 +3,7 @@ import browsersync from 'browser-sync';
3
3
  import browserReload from './build/browser.js';
4
4
  import cssTransform from './build/css.js';
5
5
  import sassCompile from './build/sass.js';
6
- import { scriptLint, scriptMinify } from './build/script.js';
6
+ import { jsLint, jsMinify } from './build/js.js';
7
7
  import shopifyFlatten from './build/shopify.js';
8
8
 
9
9
  import { parallel, series, src, watch } from './index.js';
@@ -14,7 +14,7 @@ const pattern = {
14
14
  html: `${PWD}/**/*.{html,php}`,
15
15
  sass: `${PWD}/**/{sass,scss}/**/*.{sass,scss}`,
16
16
  css: `${PWD}/**/css/**/*.css`,
17
- script: `${PWD}/**/script/**/*.js`,
17
+ js: `${PWD}/**/{js,script}/**/*.js`,
18
18
  };
19
19
 
20
20
  function sync() {
@@ -47,17 +47,17 @@ function observe() {
47
47
  watch(pattern.html, reload);
48
48
  watch(pattern.sass, series(sass, css));
49
49
  watch(pattern.css, reload);
50
- watch(pattern.script, reload);
50
+ watch(pattern.js, reload);
51
51
  }
52
52
 
53
53
  function lint() {
54
- return src(pattern.script, { ignore: ['**.min.js',], })
55
- .pipe(scriptLint);
54
+ return src(pattern.js, { ignore: ['**.min.js',], })
55
+ .pipe(jsLint);
56
56
  }
57
57
 
58
58
  function minify() {
59
- return src(pattern.script, { ignore: ['**.min.js',], })
60
- .pipe(scriptMinify)
59
+ return src(pattern.js, { ignore: ['**.min.js',], })
60
+ .pipe(jsMinify)
61
61
  .dest();
62
62
  }
63
63
 
@@ -67,7 +67,7 @@ async function shopify() {
67
67
 
68
68
  await src(`${shopifyDir}/**`).rm().toArray();
69
69
 
70
- return src(`${assetDir}/**/(css|font|gfx|plugin|script)/**`, { ignore: '**/node_modules/**', })
70
+ return src(`${assetDir}/**/(css|font|gfx|js|plugin|script)/**`, { ignore: '**/node_modules/**', })
71
71
  .pipe(shopifyFlatten)
72
72
  .dest(shopifyDir);
73
73
  }