Skip to content
This repository was archived by the owner on Feb 16, 2021. It is now read-only.

Commit bdd3aae

Browse files
committed
Merge branch 'release/0.2.0'
2 parents 033f173 + fa329da commit bdd3aae

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ What is this? For example, you have the following CSS file:
2626
color: red;
2727
}
2828
```
29-
And the plugin will give you a TypeScript file like this:
3029

31-
**componentName.ts**
30+
And the plugin will give you a TypeScript file in the same location where the CSS file is. This file generated has almost the same name, only it's added "Style" at the end of the original name of your CSS file, example:
31+
32+
**componentNameStyle.ts**
3233
```javascript
3334
export const componentNameStyle = {
3435
componentName: 'ComponentName',
@@ -41,7 +42,7 @@ So, you can import the TypeScript file
4142
**Note: you have to import first the componentName.css**
4243
```javascript
4344
import './componentName.css';
44-
import { componentNameStyle } from './componentName';
45+
import { componentNameStyle } from './componentNameStyle';
4546

4647
const element = document.createElement('div');
4748
element.className = componentNameStyle.componentName;
@@ -82,7 +83,7 @@ This will build scripts, run tests and generate a code coverage report. Anything
8283
npm test
8384
```
8485
## Example
85-
Take a look a this [repo]. Here you could see the plugin in action with webpack2 and react with TypeScript and PostCSS.
86+
Take a look a this [repo]. Here you could see the plugin in action with webpack 2 and React with TypeScript and PostCSS.
8687

8788
See [PostCSS] docs for examples for your environment.
8889

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcss-typescript-css",
3-
"version": "0.1.2",
3+
"version": "0.2.0",
44
"description": "PostCSS plugin to create a typescript file by each CSS file",
55
"main": "dist/postcss-typescript-css",
66
"scripts": {

src/saveFile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const saveFile = (file: PostcssTypescriptCss.Options) => {
1010
const dirname = path.dirname(file.cssFileName);
1111
const extension = path.extname(file.cssFileName);
1212
const filename = path.basename(file.cssFileName, extension);
13-
writeFileSync(`${dirname}/${filename}.ts`, build(file));
13+
writeFileSync(`${dirname}/${filename}Style.ts`, build(file));
1414
resolve(true);
1515
} catch (err) {
1616
reject(err.toString());

src/spec/postcss-typescript-css.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ function run(t: TestContext, input: {css: string, from: string}, opts?: PostcssT
1111
.then((result) => {
1212
let fakeComponentTS;
1313
if (opts) {
14-
fakeComponentTS = readFileSync(path.join(__dirname, 'styles/fakeComponentModules.ts'), 'utf8');
14+
fakeComponentTS = readFileSync(path.join(__dirname, 'styles/fakeComponentModulesStyle.ts'), 'utf8');
1515
t.true(fakeComponentTS.includes('fakeComponentModulesStyle'));
1616
t.true(fakeComponentTS.includes('fakeComponentModules:'));
1717
t.true(fakeComponentTS.includes('fakeComponentModulesDescendentName:'));
1818
t.true(fakeComponentTS.includes('fakeComponentModulesModifierName:'));
1919
} else {
20-
fakeComponentTS = readFileSync(path.join(__dirname, 'styles/fakeComponent.ts'), 'utf8');
20+
fakeComponentTS = readFileSync(path.join(__dirname, 'styles/fakeComponentStyle.ts'), 'utf8');
2121
t.true(fakeComponentTS.includes('fakeComponentStyle'));
2222
t.true(fakeComponentTS.includes('fakeComponent:'));
2323
t.true(fakeComponentTS.includes('fakeComponentDescendentName:'));

src/spec/saveFile.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ test('should create a new ts file', async (t) => {
99
cssFileName,
1010
content: ['.FakeComponent2', '.FakeComponent2-descendentName', '.FakeComponent2--modifierName']
1111
}), true);
12-
const tsFile = path.join(__dirname, 'styles/fakeComponent2.ts');
12+
const tsFile = path.join(__dirname, 'styles/fakeComponent2Style.ts');
1313
const tsFileName = path.basename(tsFile, '.ts');
14-
t.is(tsFileName, 'fakeComponent2');
14+
t.is(tsFileName, 'fakeComponent2Style');
1515
});
1616

1717
test('should create a new ts file with transformed classes', async (t) => {

0 commit comments

Comments
 (0)