From 0e06ad304c4787a18df7aa33b7f6fa4371a476f7 Mon Sep 17 00:00:00 2001 From: MasuqaT Date: Sat, 31 Mar 2018 00:55:33 +0900 Subject: [PATCH 1/6] Change CircleCI config. --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1d44e0f..2c2674d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -67,6 +67,8 @@ workflows: - build_6 - build_8 filters: + branches: + only: master tags: only: /v[0-9]+(\.[0-9]+)*/ - deploy: From 2b553844448e39eabbed80fe6e9bc519a91f4346 Mon Sep 17 00:00:00 2001 From: MasuqaT Date: Sat, 31 Mar 2018 00:55:57 +0900 Subject: [PATCH 2/6] Update readme. --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f9df81e..041cf71 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # transmit-update-loader + +[![CircleCI](https://circleci.com/gh/occar421/transmit-update-loader/tree/master.svg?style=svg)](https://circleci.com/gh/occar421/transmit-update-loader/tree/master) +[![Build status](https://ci.appveyor.com/api/projects/status/slqhhh1kuiatmtaf/branch/master?svg=true)](https://ci.appveyor.com/project/occar421/transmit-update-loader/branch/master) + Message passing tool to transmit update to another file during webpack loader process. -# TODO -* Options - * Transform target name - * [TBD] -* CI / CD pipeline. \ No newline at end of file +# Options TODO + +* Throttle +* [TBD] \ No newline at end of file From fb814d225098c06c623712b60ec413002a2382ae Mon Sep 17 00:00:00 2001 From: MasuqaT Date: Sun, 1 Apr 2018 16:35:55 +0900 Subject: [PATCH 3/6] Add unit test of complex replacement rule. --- test/fixtures/txt.foo | 1 + test/loader.test.js | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/fixtures/txt.foo diff --git a/test/fixtures/txt.foo b/test/fixtures/txt.foo new file mode 100644 index 0000000..84268e7 --- /dev/null +++ b/test/fixtures/txt.foo @@ -0,0 +1 @@ +TxtFoo \ No newline at end of file diff --git a/test/loader.test.js b/test/loader.test.js index 823266a..81d8785 100644 --- a/test/loader.test.js +++ b/test/loader.test.js @@ -140,3 +140,14 @@ it("should create a new file if option is set", async () => { }); expect(await existsAsync(targetFileName)).toBe(true); }); + +it("should renew txt.foo from foo.txt with complex rule", async () => { + const sourceFileName = "./fixtures/foo.txt"; + const targetFileName = "./fixtures/txt.foo"; + const preStat = await fileStatAsync(targetFileName); + await compiler(sourceFileName, { + transmitRules: [{ test: /(\w+)\.(txt$)/, targets: ["$2.$1"] }] + }); + const postStatFoo = await fileStatAsync(targetFileName); + expect(postStatFoo.ctime.getTime()).toBeGreaterThan(preStat.ctime.getTime()); +}); From d012ed58129f4767d30778b39e82eaec2dfcceab Mon Sep 17 00:00:00 2001 From: MasuqaT Date: Sun, 1 Apr 2018 16:44:05 +0900 Subject: [PATCH 4/6] Improve test around accidentally overwriting file content. --- test/loader.test.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/test/loader.test.js b/test/loader.test.js index 81d8785..2e0fdfb 100644 --- a/test/loader.test.js +++ b/test/loader.test.js @@ -8,13 +8,14 @@ import { afterEach(removeGeneratedFiles); -it("should not affect file content", async () => { - const targetFileName = "./fixtures/foo.txt"; - const status = await compiler(targetFileName, { +it("should not affect file content in webpack pipeline", async () => { + const sourceFileName = "./fixtures/foo.txt"; + const sourceFileContent = await readFileAsync(sourceFileName); + const status = await compiler(sourceFileName, { transmitRules: [{ test: /\/(.*$)/, targets: ["$1.null"] }] }); const output = status.toJson().modules[0].source; - expect(output).toBe(await readFileAsync(targetFileName)); + expect(output).toBe(sourceFileContent); }); it("should not renew itself by default", async () => { @@ -151,3 +152,25 @@ it("should renew txt.foo from foo.txt with complex rule", async () => { const postStatFoo = await fileStatAsync(targetFileName); expect(postStatFoo.ctime.getTime()).toBeGreaterThan(preStat.ctime.getTime()); }); + +it("should not affect source file content", async () => { + const sourceFileName = "./fixtures/foo.txt"; + const preSourceFileContent = await readFileAsync(sourceFileName); + await compiler(sourceFileName, { + transmitRules: [{ test: /\/(.*$)/, targets: ["$1.null"] }], + noCreate: false + }); + const postSourceFileContent = await readFileAsync(sourceFileName); + expect(postSourceFileContent).toBe(preSourceFileContent); +}); + +it("should not affect target file content", async () => { + const sourceFileName = "./fixtures/foo.txt"; + const targetFileName = "./fixtures/foo.md"; + const preTargetFileContent = await readFileAsync(targetFileName); + await compiler(sourceFileName, { + transmitRules: [{ test: /(\.txt$)/, targets: [".md"] }] + }); + const postTargetFileContent = await readFileAsync(targetFileName); + expect(postTargetFileContent).toBe(preTargetFileContent); +}); From 5e427f190531c06eb2b81cf4b5e4dc1098b8c1fc Mon Sep 17 00:00:00 2001 From: MasuqaT Date: Sun, 1 Apr 2018 17:11:23 +0900 Subject: [PATCH 5/6] Update readme. --- README.md | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 041cf71..fde04f6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,29 @@ Message passing tool to transmit update to another file during webpack loader process. -# Options TODO +# Use case -* Throttle -* [TBD] \ No newline at end of file +Assume these file structure while using CSS Modules. + +``` ++- src/ + +- Button.tsx + +- Button.css + +- Button.css.d.ts +``` + +Here, also assume we use webpack Hot Module Replacement for dev server. +When 'Button.css' is updated, 'Button.css.d.ts' could be updated. +Although, 'Button.tsx' will not be notified that 'Button.css.d.ts' is updated. +If 'Button.css's selector has changed, 'Button.tsx' won't be decorated correctly. + +Fortunately, it seems that webpack detects update with watching the same event when it is `touch`-ed. +This module helps that situation. + +'Button.css' -(generate)-> 'Button.css.d.ts' -(watch)-(`touch`)-> 'Button.tsx' recompile. + +# TODO + +* Options + * Throttle + * [TBD] \ No newline at end of file From dd6be5913630e39335c8e376d6cc7a242dc6a957 Mon Sep 17 00:00:00 2001 From: MasuqaT Date: Sun, 1 Apr 2018 17:16:10 +0900 Subject: [PATCH 6/6] Increment library version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5de2d8c..8c18d94 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "transmit-update-loader", - "version": "0.1.0", + "version": "0.1.1", "description": "Message passing tool to transmit update to another file during webpack loader process.", "main": "src/loader.js", "repository": "https://github.com/occar421/transmit-update-loader",