Skip to content
This repository was archived by the owner on Apr 1, 2022. It is now read-only.

Commit cdbe375

Browse files
committed
fixed a bug with duplicated @media rules
1 parent 616cc70 commit cdbe375

File tree

3 files changed

+123
-7
lines changed

3 files changed

+123
-7
lines changed

index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
const postcss = require('postcss');
13+
const merge = require('lodash/merge');
1314

1415
/**
1516
* Processes a breakpoint option by creating a PostCSS @media atRule from the options
@@ -60,11 +61,8 @@ function processBreakpoints(breakpointsOption) {
6061
},
6162
];
6263

63-
const processedBreakpoints = defaultBreakpoints
64-
.concat(breakpointsOption || [])
65-
.map(breakpoint => processBreakpoint(breakpoint));
66-
67-
return processedBreakpoints;
64+
const mergedBreakpoints = merge([], defaultBreakpoints, breakpointsOption);
65+
return mergedBreakpoints.map(processBreakpoint);
6866
}
6967

7068
/**
@@ -139,6 +137,8 @@ module.exports = postcss.plugin('postcss-responsify', (opts) => {
139137
root.walkAtRules('responsive', loopResponsiveRules(breakpoints));
140138

141139
/* append each breakpoint's populated atRule into the css */
142-
root.append(breakpoints.map(breakpoint => breakpoint.atRule));
140+
root.append(breakpoints.map(breakpoint => {
141+
return breakpoint.atRule;
142+
}));
143143
};
144144
});

npm-debug.log

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
0 info it worked if it ends with ok
2+
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'publish' ]
3+
2 info using npm@3.9.5
4+
3 info using node@v6.2.2
5+
4 verbose publish [ '.' ]
6+
5 silly cache add args [ '.', null ]
7+
6 verbose cache add spec .
8+
7 silly cache add parsed spec Result {
9+
7 silly cache add raw: '.',
10+
7 silly cache add scope: null,
11+
7 silly cache add name: null,
12+
7 silly cache add rawSpec: '.',
13+
7 silly cache add spec: '/Users/Derek/code/postcss-responsify',
14+
7 silly cache add type: 'directory' }
15+
8 verbose addLocalDirectory /Users/Derek/.npm/postcss-responsify/1.0.0/package.tgz not in flight; packing
16+
9 verbose correctMkdir /Users/Derek/.npm correctMkdir not in flight; initializing
17+
10 info lifecycle postcss-responsify@1.0.0~prepublish: postcss-responsify@1.0.0
18+
11 silly lifecycle postcss-responsify@1.0.0~prepublish: no script for prepublish, continuing
19+
12 verbose tar pack [ '/Users/Derek/.npm/postcss-responsify/1.0.0/package.tgz',
20+
12 verbose tar pack '/Users/Derek/code/postcss-responsify' ]
21+
13 verbose tarball /Users/Derek/.npm/postcss-responsify/1.0.0/package.tgz
22+
14 verbose folder /Users/Derek/code/postcss-responsify
23+
15 verbose addLocalTarball adding from inside cache /Users/Derek/.npm/postcss-responsify/1.0.0/package.tgz
24+
16 verbose correctMkdir /Users/Derek/.npm correctMkdir not in flight; initializing
25+
17 silly cache afterAdd postcss-responsify@1.0.0
26+
18 verbose afterAdd /Users/Derek/.npm/postcss-responsify/1.0.0/package/package.json not in flight; writing
27+
19 verbose correctMkdir /Users/Derek/.npm correctMkdir not in flight; initializing
28+
20 verbose afterAdd /Users/Derek/.npm/postcss-responsify/1.0.0/package/package.json written
29+
21 silly publish { name: 'postcss-responsify',
30+
21 silly publish version: '1.0.0',
31+
21 silly publish description: 'PostCSS plugin to automatically create responsive classes with at-rules',
32+
21 silly publish main: 'index.js',
33+
21 silly publish scripts: { test: 'echo "Error: no test specified" && exit 1' },
34+
21 silly publish repository:
35+
21 silly publish { type: 'git',
36+
21 silly publish url: 'git+https://github.com/derek-duncan/postcss-responsify.git' },
37+
21 silly publish keywords:
38+
21 silly publish [ 'postcss',
39+
21 silly publish 'postcss-plugin',
40+
21 silly publish 'responsive',
41+
21 silly publish 'stylesheet',
42+
21 silly publish 'classes',
43+
21 silly publish 'css' ],
44+
21 silly publish author: { name: 'Derek Duncan', email: 'work@derekduncan.me' },
45+
21 silly publish license: 'MIT',
46+
21 silly publish bugs: { url: 'https://github.com/derek-duncan/postcss-responsify/issues' },
47+
21 silly publish homepage: 'https://github.com/derek-duncan/postcss-responsify#readme',
48+
21 silly publish dependencies: { postcss: '^5.1.1' },
49+
21 silly publish readme: '# postcss-responsify\n[PostCSS](https://github.com/postcss/postcss) plugin to create responsive classes with the `@responsive` rule.\n\n**Config**\n```javascript\nconst postcss = require(\'postcss\');\nconst responsify = require(\'postcss-responsify\');\n\nconst breakpoints = [\n { prefix: \'sm-\', mediaQuery: \'(min-width: 40em)\' },\n { prefix: \'md-\', mediaQuery: \'(min-width: 52em)\' },\n];\nconst responsifyOptions = {\n breakpoints,\n};\npostcss().use(responsify(responsifyOptions));\n```\n\n---\n\n**Input**\n```css\n/* all rules in this tag will have generated responsive classes */\n@responsive {\n .col { float: left; box-sizing: border-box; }\n .col-1 { width: calc(1/12 * 100%); }\n .col-2 { width: calc(2/12 * 100%); }\n .col-3 { width: calc(2/12 * 100%); }\n}\n```\n\n↓\n\n**Output**\n```css\n/* unprefixed rules will be added as well */\n.col { float: left; box-sizing: border-box; }\n.col-1 { width: calc(1/12 * 100%); }\n.col-2 { width: calc(2/12 * 100%); }\n.col-3 { width: calc(2/12 * 100%); }\n\n/* prefix and media query come from plugin config */\n@media (min-width: 40em) {\n .sm-col { float: left; box-sizing: border-box; }\n .sm-col-1 { width: calc(1/12 * 100%); }\n .sm-col-2 { width: calc(2/12 * 100%); }\n .sm-col-3 { width: calc(2/12 * 100%); }\n}\n\n@media (min-width: 52em) {\n .md-col { float: left; box-sizing: border-box; }\n .md-col-1 { width: calc(1/12 * 100%); }\n .md-col-2 { width: calc(2/12 * 100%); }\n .md-col-3 { width: calc(2/12 * 100%); }\n}\n```\n',
50+
21 silly publish readmeFilename: 'README.md',
51+
21 silly publish gitHead: '39754cffdd20e52f6b6e1f217f4a0b00f5a1bbd5',
52+
21 silly publish _id: 'postcss-responsify@1.0.0',
53+
21 silly publish _shasum: '116f773ffde284793d5026ccc8d69534c7954e1c',
54+
21 silly publish _from: '.' }
55+
22 verbose getPublishConfig undefined
56+
23 silly mapToRegistry name postcss-responsify
57+
24 silly mapToRegistry using default registry
58+
25 silly mapToRegistry registry https://registry.npmjs.org/
59+
26 silly mapToRegistry data Result {
60+
26 silly mapToRegistry raw: 'postcss-responsify',
61+
26 silly mapToRegistry scope: null,
62+
26 silly mapToRegistry name: 'postcss-responsify',
63+
26 silly mapToRegistry rawSpec: '',
64+
26 silly mapToRegistry spec: 'latest',
65+
26 silly mapToRegistry type: 'tag' }
66+
27 silly mapToRegistry uri https://registry.npmjs.org/postcss-responsify
67+
28 verbose publish registryBase https://registry.npmjs.org/
68+
29 silly publish uploading /Users/Derek/.npm/postcss-responsify/1.0.0/package.tgz
69+
30 verbose request uri https://registry.npmjs.org/postcss-responsify
70+
31 verbose request sending authorization for write operation
71+
32 info attempt registry request try #1 at 9:30:20 PM
72+
33 verbose request using bearer token for auth
73+
34 verbose request id ba595b292a67c4cf
74+
35 http request PUT https://registry.npmjs.org/postcss-responsify
75+
36 info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
76+
37 info attempt registry request try #2 at 9:30:30 PM
77+
38 verbose request using bearer token for auth
78+
39 http request PUT https://registry.npmjs.org/postcss-responsify
79+
40 http 403 https://registry.npmjs.org/postcss-responsify
80+
41 verbose headers { 'content-type': 'application/json',
81+
41 verbose headers 'cache-control': 'max-age=300',
82+
41 verbose headers 'content-length': '95',
83+
41 verbose headers 'accept-ranges': 'bytes',
84+
41 verbose headers date: 'Sat, 13 Aug 2016 02:30:31 GMT',
85+
41 verbose headers via: '1.1 varnish',
86+
41 verbose headers connection: 'keep-alive',
87+
41 verbose headers 'x-served-by': 'cache-dfw1836-DFW',
88+
41 verbose headers 'x-cache': 'MISS',
89+
41 verbose headers 'x-cache-hits': '0',
90+
41 verbose headers 'x-timer': 'S1471055430.777568,VS0,VE1127',
91+
41 verbose headers vary: 'Accept-Encoding' }
92+
42 verbose request invalidating /Users/Derek/.npm/registry.npmjs.org/postcss-responsify on PUT
93+
43 error publish Failed PUT 403
94+
44 verbose stack Error: "You cannot publish over the previously published version 1.0.0." : postcss-responsify
95+
44 verbose stack at makeError (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:264:12)
96+
44 verbose stack at CachingRegistryClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:252:14)
97+
44 verbose stack at Request._callback (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:172:14)
98+
44 verbose stack at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:200:22)
99+
44 verbose stack at emitTwo (events.js:106:13)
100+
44 verbose stack at Request.emit (events.js:191:7)
101+
44 verbose stack at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1067:10)
102+
44 verbose stack at emitOne (events.js:101:20)
103+
44 verbose stack at Request.emit (events.js:188:7)
104+
44 verbose stack at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:988:12)
105+
45 verbose statusCode 403
106+
46 verbose pkgid postcss-responsify
107+
47 verbose cwd /Users/Derek/code/postcss-responsify
108+
48 error Darwin 15.6.0
109+
49 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "publish"
110+
50 error node v6.2.2
111+
51 error npm v3.9.5
112+
52 error code E403
113+
53 error "You cannot publish over the previously published version 1.0.0." : postcss-responsify
114+
54 error If you need help, you may report this error at:
115+
54 error <https://github.com/npm/npm/issues>
116+
55 verbose exit [ 1, true ]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcss-responsify",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "PostCSS plugin to automatically create responsive classes with at-rules",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)