customizr 2.0.0 → 2.0.4

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/test/pretest.js CHANGED
@@ -1,133 +1,133 @@
1
- "use strict";
2
-
3
- var fs = require("fs-extra");
4
- var cwd = process.cwd();
5
- var path = require("path");
6
-
7
- var buildDir = path.join(cwd, "build");
8
-
9
- if (fs.existsSync(buildDir)) {
10
- console.log("Removing old build folder...");
11
- fs.removeSync(buildDir);
12
- console.log("Done.");
13
- }
14
-
15
- var modernizr = require("modernizr");
16
-
17
- modernizr.metadata(function (metadata) {
18
- var props = metadata.map(function (data) {
19
- return {
20
- name: data.name,
21
- path: data.amdPath.replace("test/", ""),
22
- property: data.property,
23
- cssclass: data.cssclass
24
- };
25
- });
26
-
27
- var jsProps = props.filter(function (data) {
28
- return data.property;
29
- });
30
-
31
- var jsTests = {};
32
-
33
- jsProps.forEach(function (prop) {
34
- var sections = prop.path.split("/");
35
- var maxLength = sections.length - 1;
36
- var current = jsTests;
37
-
38
- if (sections.length === 1) {
39
- current.standalone = current.standalone || {};
40
- current.standalone[sections[0]] = prop.property;
41
- } else {
42
- sections.forEach(function (sect, idx) {
43
- if (idx === maxLength) {
44
- current[sect] = prop.property;
45
- } else {
46
- current[sect] = current[sect] || {};
47
- }
48
-
49
- current = current[sect];
50
- });
51
- }
52
- });
53
-
54
- var string = JSON.stringify(jsTests, null, "\t");
55
-
56
- // Convert "foo": "bar" -> "foo": Modernizr.bar
57
- string = string.replace(/(\:(?:\s)?)\"(.*)\"/g, "$1Modernizr.$2");
58
-
59
- // Convert [ "foo": "bar" ] -> [ "foo": Modernizr["bar"] ]
60
- string = string.replace(/(\t{3})\"(.*)\"/g, "$1Modernizr[\"$2\"]");
61
-
62
- // Convert Modernizr.foo-bar -> Modernizr["foo-bar"]
63
- string = string.replace(/\.((?:[\w]+)?\-(?:[\w]+))/g, "[\"$1\"]");
64
-
65
- // Save test/js/vanilla.js
66
- (function () {
67
- var vanilla = [
68
- "var Modernizr = window.Modernizr;",
69
- "var tests = " + string + ";"
70
- ].join("\n\n");
71
-
72
- fs.writeFileSync(path.join(cwd, "test", "js", "vanilla.js"), vanilla);
73
- }());
74
-
75
- // Save test/js/amd.js
76
- (function () {
77
- var amd = [
78
- "/* global define */",
79
- "define([\"Modernizr\"], function (M) {",
80
- " var tests = " + string.replace(/\n/g, "\n\t").replace(/Modernizr/g, "M") + ";",
81
- " return M;",
82
- "});"
83
- ].join("\n\n");
84
-
85
- fs.writeFileSync(path.join(cwd, "test", "js", "amd.js"), amd);
86
- }());
87
-
88
- // Save test/css/vanilla.css
89
- (function () {
90
- var cssProps = props.filter(function (data) {
91
- return data.cssclass;
92
- }).map(function (data, idx) {
93
- var cssclass = Array.isArray(data.cssclass) ? data.cssclass : [data.cssclass];
94
- var negateclass = (idx % 2 ? "no-" : "");
95
-
96
- return "." + negateclass + cssclass.join(", .");
97
- });
98
-
99
- var css = [
100
- cssProps.join(",\n") + " {",
101
- "\tbackground: red;",
102
- "}\n\n"
103
- ].join("\n");
104
-
105
- // Take a few classes and add a prefix for testing.
106
- var prefixed = [
107
- ".prefixed-cors",
108
- ".prefixed-input",
109
- ".prefixed-no-smil"
110
- ];
111
-
112
- css += [
113
- prefixed.join(",\n") + " {",
114
- "\tbackground: blue;",
115
- "}\n"
116
- ].join("\n");
117
-
118
- fs.writeFileSync(path.join(cwd, "test", "css", "vanilla.css"), css);
119
- }());
120
-
121
- var missingData = props.filter(function (data) {
122
- return !data.property && !data.cssclass;
123
- }).map(function (data) {
124
- return data.path;
125
- });
126
-
127
- if (missingData.length) {
128
- console.log("\n");
129
- console.log("The following tests have no metadata:");
130
- console.log();
131
- console.log(missingData.join("\n"));
132
- }
133
- });
1
+ "use strict";
2
+
3
+ var fs = require("fs-extra");
4
+ var cwd = process.cwd();
5
+ var path = require("path");
6
+
7
+ var buildDir = path.join(cwd, "build");
8
+
9
+ if (fs.existsSync(buildDir)) {
10
+ console.log("Removing old build folder...");
11
+ fs.removeSync(buildDir);
12
+ console.log("Done.");
13
+ }
14
+
15
+ var modernizr = require("modernizr");
16
+
17
+ modernizr.metadata(function (metadata) {
18
+ var props = metadata.map(function (data) {
19
+ return {
20
+ name: data.name,
21
+ path: data.amdPath.replace("test/", ""),
22
+ property: data.property,
23
+ cssclass: data.cssclass
24
+ };
25
+ });
26
+
27
+ var jsProps = props.filter(function (data) {
28
+ return data.property;
29
+ });
30
+
31
+ var jsTests = {};
32
+
33
+ jsProps.forEach(function (prop) {
34
+ var sections = prop.path.split("/");
35
+ var maxLength = sections.length - 1;
36
+ var current = jsTests;
37
+
38
+ if (sections.length === 1) {
39
+ current.standalone = current.standalone || {};
40
+ current.standalone[sections[0]] = prop.property;
41
+ } else {
42
+ sections.forEach(function (sect, idx) {
43
+ if (idx === maxLength) {
44
+ current[sect] = prop.property;
45
+ } else {
46
+ current[sect] = current[sect] || {};
47
+ }
48
+
49
+ current = current[sect];
50
+ });
51
+ }
52
+ });
53
+
54
+ var string = JSON.stringify(jsTests, null, "\t");
55
+
56
+ // Convert "foo": "bar" -> "foo": Modernizr.bar
57
+ string = string.replace(/(\:(?:\s)?)\"(.*)\"/g, "$1Modernizr.$2");
58
+
59
+ // Convert [ "foo": "bar" ] -> [ "foo": Modernizr["bar"] ]
60
+ string = string.replace(/(\t{3})\"(.*)\"/g, "$1Modernizr[\"$2\"]");
61
+
62
+ // Convert Modernizr.foo-bar -> Modernizr["foo-bar"]
63
+ string = string.replace(/\.((?:[\w]+)?\-(?:[\w]+))/g, "[\"$1\"]");
64
+
65
+ // Save test/js/vanilla.js
66
+ (function () {
67
+ var vanilla = [
68
+ "var Modernizr = window.Modernizr;",
69
+ "var tests = " + string + ";"
70
+ ].join("\n\n");
71
+
72
+ fs.writeFileSync(path.join(cwd, "test", "js", "vanilla.js"), vanilla);
73
+ }());
74
+
75
+ // Save test/js/amd.js
76
+ (function () {
77
+ var amd = [
78
+ "/* global define */",
79
+ "define([\"Modernizr\"], function (M) {",
80
+ " var tests = " + string.replace(/\n/g, "\n\t").replace(/Modernizr/g, "M") + ";",
81
+ " return M;",
82
+ "});"
83
+ ].join("\n\n");
84
+
85
+ fs.writeFileSync(path.join(cwd, "test", "js", "amd.js"), amd);
86
+ }());
87
+
88
+ // Save test/css/vanilla.css
89
+ (function () {
90
+ var cssProps = props.filter(function (data) {
91
+ return data.cssclass;
92
+ }).map(function (data, idx) {
93
+ var cssclass = Array.isArray(data.cssclass) ? data.cssclass : [data.cssclass];
94
+ var negateclass = (idx % 2 ? "no-" : "");
95
+
96
+ return "." + negateclass + cssclass.join(", .");
97
+ });
98
+
99
+ var css = [
100
+ cssProps.join(",\n") + " {",
101
+ "\tbackground: red;",
102
+ "}\n\n"
103
+ ].join("\n");
104
+
105
+ // Take a few classes and add a prefix for testing.
106
+ var prefixed = [
107
+ ".prefixed-cors",
108
+ ".prefixed-input",
109
+ ".prefixed-no-smil"
110
+ ];
111
+
112
+ css += [
113
+ prefixed.join(",\n") + " {",
114
+ "\tbackground: blue;",
115
+ "}\n"
116
+ ].join("\n");
117
+
118
+ fs.writeFileSync(path.join(cwd, "test", "css", "vanilla.css"), css);
119
+ }());
120
+
121
+ var missingData = props.filter(function (data) {
122
+ return !data.property && !data.cssclass;
123
+ }).map(function (data) {
124
+ return data.path;
125
+ });
126
+
127
+ if (missingData.length) {
128
+ console.log("\n");
129
+ console.log("The following tests have no metadata:");
130
+ console.log();
131
+ console.log(missingData.join("\n"));
132
+ }
133
+ });
package/test/runner.js CHANGED
@@ -1,17 +1,17 @@
1
- var Mocha = require("mocha");
2
-
3
- var mocha = new Mocha({
4
- setup : "bdd",
5
- reporter : process.env.TRAVIS ? "tap" : "spec",
6
- slow : 5000,
7
- timeout : 30000
8
- });
9
-
10
- mocha.addFile("test/tests.js");
11
-
12
- var runner = mocha.run();
13
-
14
- runner.on("fail", function (test, err) {
15
- process.stderr.write(" " + err.toString() + "\n\n");
16
- process.exit(1);
17
- });
1
+ var Mocha = require("mocha");
2
+
3
+ var mocha = new Mocha({
4
+ setup : "bdd",
5
+ reporter : process.env.TRAVIS ? "tap" : "spec",
6
+ slow : 5000,
7
+ timeout : 30000
8
+ });
9
+
10
+ mocha.addFile("test/tests.js");
11
+
12
+ var runner = mocha.run();
13
+
14
+ runner.on("fail", function (test, err) {
15
+ process.stderr.write(" " + err.toString() + "\n\n");
16
+ process.exit(1);
17
+ });
@@ -1,9 +1,9 @@
1
- {
2
- "dest": "build/modernizr-custom.js",
3
- "cache": false,
4
- "files": {
5
- "src": [
6
- "test/{js,css}/*"
7
- ]
8
- }
9
- }
1
+ {
2
+ "dest": "build/modernizr-custom.js",
3
+ "cache": false,
4
+ "files": {
5
+ "src": [
6
+ "test/{js,css}/*"
7
+ ]
8
+ }
9
+ }
@@ -1,8 +1,8 @@
1
- {
2
- "dest": "build/modernizr-custom.js",
3
- "files": {
4
- "src": [
5
- "test/{js,css}/*"
6
- ]
7
- }
8
- }
1
+ {
2
+ "dest": "build/modernizr-custom.js",
3
+ "files": {
4
+ "src": [
5
+ "test/{js,css}/*"
6
+ ]
7
+ }
8
+ }
@@ -1,14 +1,14 @@
1
- {
2
- "dest": "build/modernizr-exclude.js",
3
- "excludeTests": [
4
- "applicationcache",
5
- "emoji",
6
- "notification"
7
- ],
8
- "files": {
9
- "src": [
10
- "test/{js,css}/*"
11
- ]
12
- },
13
- "uglify": false
14
- }
1
+ {
2
+ "dest": "build/modernizr-exclude.js",
3
+ "excludeTests": [
4
+ "applicationcache",
5
+ "emoji",
6
+ "notification"
7
+ ],
8
+ "files": {
9
+ "src": [
10
+ "test/{js,css}/*"
11
+ ]
12
+ },
13
+ "uglify": false
14
+ }
@@ -1,10 +1,10 @@
1
- {
2
- "classPrefix": "prefixed-",
3
- "dest": "build/modernizr-prefixed.js",
4
- "uglify": false,
5
- "files": {
6
- "src": [
7
- "test/css/*.css"
8
- ]
9
- }
10
- }
1
+ {
2
+ "classPrefix": "prefixed-",
3
+ "dest": "build/modernizr-prefixed.js",
4
+ "uglify": false,
5
+ "files": {
6
+ "src": [
7
+ "test/css/*.css"
8
+ ]
9
+ }
10
+ }
@@ -1,15 +1,15 @@
1
- {
2
- "dest": "build/modernizr-select.js",
3
- "tests": [
4
- ["cssgrid", "cssgridlegacy"],
5
- "siblinggeneral",
6
- "svg"
7
- ],
8
- "files": {
9
- "src": [
10
- "test/{js,css}/*"
11
- ]
12
- },
13
- "crawl": false,
14
- "uglify": false
15
- }
1
+ {
2
+ "dest": "build/modernizr-select.js",
3
+ "tests": [
4
+ ["cssgrid", "cssgridlegacy"],
5
+ "siblinggeneral",
6
+ "svg"
7
+ ],
8
+ "files": {
9
+ "src": [
10
+ "test/{js,css}/*"
11
+ ]
12
+ },
13
+ "crawl": false,
14
+ "uglify": false
15
+ }