Skip to content

Commit

Permalink
fix(assetsDirs): allow same destination asset dir copy task
Browse files Browse the repository at this point in the history
Closes #2615
  • Loading branch information
adamdbradley committed Aug 6, 2020
1 parent 762160a commit b6379b3
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/sys/deno/deno-copy-tasks.ts
@@ -1,6 +1,6 @@
import type * as d from '../../declarations';
import type { Deno } from '../../../types/lib.deno';
import { buildError, catchError, flatOne, normalizePath, unique } from '@utils';
import { buildError, catchError, flatOne, normalizePath } from '@utils';
import { basename, dirname, expandGlob, isGlob, isAbsolute, join, resolve } from './deps';

export async function denoCopyTasks(deno: typeof Deno, copyTasks: Required<d.CopyTask>[], srcDir: string) {
Expand All @@ -13,8 +13,6 @@ export async function denoCopyTasks(deno: typeof Deno, copyTasks: Required<d.Cop
try {
copyTasks = flatOne(await Promise.all(copyTasks.map(task => processGlobs(task, srcDir))));

copyTasks = unique(copyTasks, task => task.dest);

const allCopyTasks: d.CopyTask[] = [];

// figure out all the file copy tasks we'll have
Expand Down
4 changes: 1 addition & 3 deletions src/sys/node/node-copy-tasks.ts
@@ -1,5 +1,5 @@
import * as d from '../../declarations';
import { buildError, catchError, flatOne, isGlob, normalizePath, unique } from '@utils';
import { buildError, catchError, flatOne, isGlob, normalizePath } from '@utils';
import { copyFile, mkdir, readdir, stat } from './node-fs-promisify';
import path from 'path';
import glob from 'glob';
Expand All @@ -14,8 +14,6 @@ export async function nodeCopyTasks(copyTasks: Required<d.CopyTask>[], srcDir: s
try {
copyTasks = flatOne(await Promise.all(copyTasks.map(task => processGlobs(task, srcDir))));

copyTasks = unique(copyTasks, task => task.dest);

const allCopyTasks: d.CopyTask[] = [];

// figure out all the file copy tasks we'll have
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/src/car-detail/assets-a/file-1.txt
@@ -0,0 +1 @@
file-1.txt
4 changes: 2 additions & 2 deletions test/end-to-end/src/car-detail/car-detail.tsx
@@ -1,9 +1,9 @@
import { Component, Prop, h } from '@stencil/core';
import { CarData } from '../car-list/car-data';


@Component({
tag: 'car-detail'
tag: 'car-detail',
assetsDirs: ['assets-a'],
})
export class CarDetail {
@Prop() car: CarData;
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/src/car-list/assets-a/file-2.txt
@@ -0,0 +1 @@
file-2.txt
3 changes: 2 additions & 1 deletion test/end-to-end/src/car-list/car-list.tsx
Expand Up @@ -9,7 +9,8 @@ import { CarData } from './car-data';
@Component({
tag: 'car-list',
styleUrl: 'car-list.css',
shadow: true
shadow: true,
assetsDirs: ['assets-a'],
})
export class CarList {
@Prop() cars: CarData[];
Expand Down
1 change: 1 addition & 0 deletions test/end-to-end/src/dom-api/assets-b/file-3.txt
@@ -0,0 +1 @@
file-3.txt
4 changes: 2 additions & 2 deletions test/end-to-end/src/dom-api/dom-api.tsx
@@ -1,10 +1,10 @@
import { Component, h } from '@stencil/core';

@Component({
tag: 'dom-api'
tag: 'dom-api',
assetsDirs: ['assets-b'],
})
export class DomApiCmp {

render() {
return (
<span data-z="z" class="red green blue" data-a="a">
Expand Down
4 changes: 4 additions & 0 deletions test/end-to-end/test-end-to-end-dist.js
Expand Up @@ -32,6 +32,10 @@ fs.accessSync(path.join(typesDir, 'car-list', 'car-list.d.ts'));
const wwwDir = path.join(__dirname, 'www');
fs.accessSync(path.join(wwwDir, 'build', 'endtoend.js'));
fs.accessSync(path.join(wwwDir, 'build', 'endtoend.esm.js'));
fs.accessSync(path.join(wwwDir, 'build', 'endtoend.css'));
fs.accessSync(path.join(wwwDir, 'build', 'assets-a/file-1.txt'));
fs.accessSync(path.join(wwwDir, 'build', 'assets-a/file-2.txt'));
fs.accessSync(path.join(wwwDir, 'build', 'assets-b/file-3.txt'));
fs.accessSync(path.join(wwwDir, 'index.html'));

fs.accessSync(path.join(__dirname, 'dist-react', 'components.ts'));
Expand Down

0 comments on commit b6379b3

Please sign in to comment.