gulp-preprocess 5.0.0 → 6.0.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.
@@ -5,11 +5,13 @@ jobs:
5
5
  runs-on: ubuntu-latest
6
6
  strategy:
7
7
  matrix:
8
- node: [18, 20, 21]
8
+ node: ["lts/*", "node"]
9
9
  steps:
10
10
  - uses: actions/checkout@v4
11
11
  - uses: actions/setup-node@v4
12
12
  with:
13
13
  node-version: ${{ matrix.node }}
14
14
  - run: npm install
15
- - run: npm run test
15
+ - run: npm run format:check
16
+ - run: npm run lint
17
+ - run: npm test
package/.oxignore ADDED
@@ -0,0 +1,2 @@
1
+ test/expected/**
2
+ test/fixtures/**
package/.oxlintrc.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "env": {
3
+ "node": true,
4
+ "es6": true
5
+ }
6
+ }
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # gulp-preprocess [![NPM version](https://img.shields.io/npm/v/gulp-preprocess.svg)](https://www.npmjs.com/package/gulp-preprocess) [![Run tests](https://github.com/nfroidure/svg-pathdata/actions/workflows/test.yml/badge.svg)](https://github.com/nfroidure/svg-pathdata/actions/workflows/test.yml)
1
+ # gulp-preprocess [![NPM version](https://img.shields.io/npm/v/gulp-preprocess.svg)](https://www.npmjs.com/package/gulp-preprocess) [![Run tests](https://github.com/pioug/gulp-preprocess/actions/workflows/test.yaml/badge.svg)](https://github.com/pioug/gulp-preprocess/actions/workflows/test.yaml)
2
2
 
3
3
  > [Gulp](http://gulpjs.com) plugin to preprocess HTML, JavaScript, and other files based on custom context or environment configuration
4
4
 
@@ -10,7 +10,7 @@
10
10
  </tr>
11
11
  <tr>
12
12
  <td>Node Version</td>
13
- <td>>= 18</td>
13
+ <td>>= 24</td>
14
14
  </tr>
15
15
  <tr>
16
16
  <td>Gulp Version</td>
@@ -36,7 +36,7 @@ var preprocess = require("gulp-preprocess");
36
36
  gulp.task("html", function () {
37
37
  gulp
38
38
  .src("./app/*.html")
39
- .pipe(preprocess({ context: { NODE_ENV: "production", DEBUG: true } })) // To set environment variables in-line
39
+ .pipe(preprocess({ context: { NODE_ENV: "production", DEBUG: true } })) // To set environment variables inline
40
40
  .pipe(gulp.dest("./dist/"));
41
41
  });
42
42
 
@@ -54,14 +54,16 @@ gulp.task("scripts", function () {
54
54
  <!-- @if NODE_ENV='production' -->
55
55
  <script src="some/production/lib/like/analytics.js"></script>
56
56
  <!-- @endif -->
57
-
58
57
  </head>
59
58
  <body>
60
59
  <!-- @ifdef DEBUG -->
61
- <h1>Debugging mode - <!-- @echo RELEASE_TAG --> </h1>
60
+ <h1>
61
+ Debugging mode -
62
+ <!-- @echo RELEASE_TAG -->
63
+ </h1>
62
64
  <!-- @endif -->
63
65
  <p>
64
- <!-- @include welcome_message.txt -->
66
+ <!-- @include welcome_message.txt -->
65
67
  </p>
66
68
  </body>
67
69
  ```
@@ -91,7 +93,7 @@ CoffeeScript files are also supported.
91
93
  Type: `Object`
92
94
  Default: `{}`
93
95
 
94
- Context for directives used in your preprocessed files. The default context consists of the current user environment variables. Custom context is merged with `process.env`.
96
+ Context for directives used in your preprocessed files. The default context consists of the current environment variables. Custom context is merged with `process.env`.
95
97
 
96
98
  #### options.includeBase
97
99
 
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var pp = require("preprocess");
2
2
  var path = require("path");
3
- var through = require('through2');
3
+ var Transform = require("node:stream").Transform;
4
4
 
5
5
  module.exports = function (options) {
6
6
  var opts = Object.assign({}, options);
@@ -11,8 +11,7 @@ module.exports = function (options) {
11
11
 
12
12
  // TODO: support streaming files
13
13
  if (file.isNull()) return callback(null, file); // pass along
14
- if (file.isStream())
15
- return callback(new Error("gulp-preprocess: Streaming not supported"));
14
+ if (file.isStream()) return callback(new Error("gulp-preprocess: Streaming not supported"));
16
15
 
17
16
  context.src = file.path;
18
17
  context.srcDir = opts.includeBase || path.dirname(file.path);
@@ -27,7 +26,10 @@ module.exports = function (options) {
27
26
  callback(null, file);
28
27
  }
29
28
 
30
- return through.obj(ppStream);
29
+ return new Transform({
30
+ objectMode: true,
31
+ transform: ppStream,
32
+ });
31
33
  };
32
34
 
33
35
  function getExtension(filename) {
package/package.json CHANGED
@@ -1,53 +1,52 @@
1
1
  {
2
2
  "name": "gulp-preprocess",
3
+ "version": "6.0.0",
3
4
  "description": "Gulp plugin to preprocess HTML, JavaScript, and other files based on custom context or environment configuration",
4
- "version": "5.0.0",
5
- "homepage": "http://github.com/pioug/gulp-preprocess",
5
+ "keywords": [
6
+ "ENV",
7
+ "coffeescript",
8
+ "conditional",
9
+ "debug",
10
+ "echo",
11
+ "environment",
12
+ "exclude",
13
+ "gulp-plugin",
14
+ "gulpplugin",
15
+ "html",
16
+ "ifdef",
17
+ "ifndef",
18
+ "include",
19
+ "javascript",
20
+ "preprocessor"
21
+ ],
22
+ "bugs": {
23
+ "url": "https://github.com/pioug/gulp-preprocess/issues"
24
+ },
25
+ "license": "MIT",
26
+ "author": "Jason Sandmeyer",
6
27
  "repository": {
7
28
  "type": "git",
8
- "url": "http://github.com/pioug/gulp-preprocess.git"
29
+ "url": "git+https://github.com/pioug/gulp-preprocess.git"
30
+ },
31
+ "main": "index.js",
32
+ "exports": "./index.js",
33
+ "scripts": {
34
+ "format": "oxfmt --write \"**/*.{js,json,yml,yaml,md}\" --ignore-path .oxignore",
35
+ "format:check": "oxfmt --check \"**/*.{js,json,yml,yaml,md}\" --ignore-path .oxignore",
36
+ "lint": "oxlint --deny-warnings . --ignore-path .oxignore",
37
+ "prepublishOnly": "npm run format:check && npm run lint && npm test",
38
+ "test": "mocha"
9
39
  },
10
- "author": "Jason Sandmeyer",
11
- "main": "./index.js",
12
40
  "dependencies": {
13
- "preprocess": "^3.0.0",
14
- "through2": "^4.0.2"
41
+ "preprocess": "^3.0.0"
15
42
  },
16
43
  "devDependencies": {
17
- "eslint": "^8.57.0",
18
- "mocha": "^10.3.0",
19
- "prettier": "^3.2.5",
20
- "should": "^13.2.3",
44
+ "mocha": "^12.0.0-beta-9",
45
+ "oxfmt": "^0.32.0",
46
+ "oxlint": "^1.47.0",
21
47
  "vinyl": "^3.0.0"
22
48
  },
23
49
  "engines": {
24
- "node": ">= 18"
25
- },
26
- "scripts": {
27
- "test": "mocha --reporter spec"
28
- },
29
- "bugs": {
30
- "url": "https://github.com/pioug/gulp-preprocess/issues"
31
- },
32
- "directories": {
33
- "test": "test"
34
- },
35
- "keywords": [
36
- "gulpplugin",
37
- "gulp-plugin",
38
- "preprocessor",
39
- "html",
40
- "javascript",
41
- "coffeescript",
42
- "debug",
43
- "environment",
44
- "ENV",
45
- "conditional",
46
- "include",
47
- "exclude",
48
- "ifdef",
49
- "ifndef",
50
- "echo"
51
- ],
52
- "license": "MIT"
50
+ "node": ">=24.0.0"
51
+ }
53
52
  }
package/test/main.js CHANGED
@@ -1,4 +1,4 @@
1
- var should = require("should");
1
+ var assert = require("assert");
2
2
  var File = require("vinyl");
3
3
  var preprocess = require("../");
4
4
  var fs = require("fs");
@@ -10,132 +10,129 @@ function fixtureFile(fileName) {
10
10
  base: "test/fixtures",
11
11
  cwd: "test/",
12
12
  path: "test/fixtures/" + fileName,
13
- contents: fs.readFileSync("test/fixtures/" + fileName)
13
+ contents: fs.readFileSync("test/fixtures/" + fileName),
14
14
  });
15
15
  }
16
16
 
17
17
  process.env["FAKEHOME"] = "/Users/jas";
18
18
 
19
- describe("gulp-preprocess", function() {
20
- describe("preprocess()", function() {
21
- it("should preprocess html", function(done) {
19
+ describe("gulp-preprocess", function () {
20
+ describe("preprocess()", function () {
21
+ it("should preprocess html", function (done) {
22
22
  var stream = preprocess({
23
23
  context: {
24
24
  firstOption: "bar",
25
- secondOption: "foo"
26
- }
25
+ secondOption: "foo",
26
+ },
27
27
  });
28
28
 
29
29
  var fakeFile = fixtureFile("test.html");
30
30
 
31
- stream.once("data", function(newFile) {
32
- should.exist(newFile);
33
- should.exist(newFile.contents);
34
- String(newFile.contents).should.equal(
35
- fs.readFileSync("test/expected/test.html", "utf8")
36
- );
31
+ stream.once("data", function (newFile) {
32
+ assert(newFile);
33
+ assert(newFile.contents);
34
+ assert.equal(String(newFile.contents), fs.readFileSync("test/expected/test.html", "utf8"));
37
35
  done();
38
36
  });
39
37
  stream.write(fakeFile);
40
38
  });
41
39
 
42
- it("should preprocess javascript", function(done) {
40
+ it("should preprocess javascript", function (done) {
43
41
  var stream = preprocess({
44
42
  context: {
45
43
  firstOption: "bar",
46
- secondOption: "foo"
47
- }
44
+ secondOption: "foo",
45
+ },
48
46
  });
49
47
 
50
48
  var fakeFile = fixtureFile("test.js");
51
49
 
52
- stream.once("data", function(newFile) {
53
- should.exist(newFile);
54
- should.exist(newFile.contents);
55
- String(newFile.contents).should.equal(
56
- fs.readFileSync("test/expected/test.js", "utf8")
57
- );
50
+ stream.once("data", function (newFile) {
51
+ assert(newFile);
52
+ assert(newFile.contents);
53
+ assert.equal(String(newFile.contents), fs.readFileSync("test/expected/test.js", "utf8"));
58
54
  done();
59
55
  });
60
56
  stream.write(fakeFile);
61
57
  });
62
58
 
63
- it("should preprocess coffeescript", function(done) {
59
+ it("should preprocess coffeescript", function (done) {
64
60
  var stream = preprocess({
65
61
  context: {
66
62
  firstOption: "bar",
67
- secondOption: "foo"
68
- }
63
+ secondOption: "foo",
64
+ },
69
65
  });
70
66
 
71
67
  var fakeFile = fixtureFile("test.coffee");
72
68
 
73
- stream.once("data", function(newFile) {
74
- should.exist(newFile);
75
- should.exist(newFile.contents);
76
- String(newFile.contents).should.equal(
77
- fs.readFileSync("test/expected/test.coffee", "utf8")
69
+ stream.once("data", function (newFile) {
70
+ assert(newFile);
71
+ assert(newFile.contents);
72
+ assert.equal(
73
+ String(newFile.contents),
74
+ fs.readFileSync("test/expected/test.coffee", "utf8"),
78
75
  );
79
76
  done();
80
77
  });
81
78
  stream.write(fakeFile);
82
79
  });
83
80
 
84
- it("should preprocess without options object", function(done) {
81
+ it("should preprocess without options object", function (done) {
85
82
  var stream = preprocess();
86
83
 
87
84
  var fakeFile = fixtureFile("test.coffee");
88
85
 
89
- stream.once("data", function(newFile) {
90
- should.exist(newFile);
91
- should.exist(newFile.contents);
92
- String(newFile.contents).should.equal(
93
- fs.readFileSync("test/expected/test.coffee", "utf8")
86
+ stream.once("data", function (newFile) {
87
+ assert(newFile);
88
+ assert(newFile.contents);
89
+ assert.equal(
90
+ String(newFile.contents),
91
+ fs.readFileSync("test/expected/test.coffee", "utf8"),
94
92
  );
95
93
  done();
96
94
  });
97
95
  stream.write(fakeFile);
98
96
  });
99
97
 
100
- it("should preprocess html with custom base", function(done) {
98
+ it("should preprocess html with custom base", function (done) {
101
99
  var stream = preprocess({
102
100
  includeBase: "test/fixtures/base",
103
101
  context: {
104
102
  firstOption: "bar",
105
- secondOption: "foo"
106
- }
103
+ secondOption: "foo",
104
+ },
107
105
  });
108
106
 
109
107
  var fakeFile = fixtureFile("test.html");
110
108
 
111
- stream.once("data", function(newFile) {
112
- should.exist(newFile);
113
- should.exist(newFile.contents);
114
- String(newFile.contents).should.equal(
115
- fs.readFileSync("test/expected/test-base.html", "utf8")
109
+ stream.once("data", function (newFile) {
110
+ assert(newFile);
111
+ assert(newFile.contents);
112
+ assert.equal(
113
+ String(newFile.contents),
114
+ fs.readFileSync("test/expected/test-base.html", "utf8"),
116
115
  );
117
116
  done();
118
117
  });
119
118
  stream.write(fakeFile);
120
119
  });
121
120
 
122
- it("should allow custom extension", function(done) {
121
+ it("should allow custom extension", function (done) {
123
122
  var stream = preprocess({
124
123
  extension: "html",
125
124
  context: {
126
125
  firstOption: "bar",
127
- secondOption: "foo"
128
- }
126
+ secondOption: "foo",
127
+ },
129
128
  });
130
129
 
131
130
  var fakeFile = fixtureFile("test.php");
132
131
 
133
- stream.once("data", function(newFile) {
134
- should.exist(newFile);
135
- should.exist(newFile.contents);
136
- String(newFile.contents).should.equal(
137
- fs.readFileSync("test/expected/test.html", "utf8")
138
- );
132
+ stream.once("data", function (newFile) {
133
+ assert(newFile);
134
+ assert(newFile.contents);
135
+ assert.equal(String(newFile.contents), fs.readFileSync("test/expected/test.html", "utf8"));
139
136
  done();
140
137
  });
141
138
  stream.write(fakeFile);
package/.eslintrc DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "eslint:recommended",
3
- "parserOptions": {
4
- "ecmaVersion": "latest"
5
- },
6
- "env": {
7
- "node": true,
8
- "mocha": true
9
- }
10
- }