ttmt ttmt - 1 year ago 84
TypeScript Question

Shell command to copy just html files to the correct folder

I'm creating a build script using npm.

The build script includes typescript compiling.

The typescript compiling copies the folder structure from a ts folder to a dist/js folder.

The ts folder is like

-- one
-- one.html
-- one.ts

-- two.html
-- two.ts

And the dist/js folder created is like

-- one
-- one.js

-- two.js

The ts folders always contain html that I need to copy to the js after the compiling has run.

What shell command can I use to copy the html from the ts folder to the correct folder in the outputed js folder.


I have tried the following command

"build:copy-html": "find ./app/ts -name '*.html' cp ./dist/js \\;",

but get an error of

find: cp: unknown primary or operator


In the ts folder I have


I need the js folder to be


Answer Source

I usually do the following:

  (cd app/ts; tar -cf - `find . -name '*.html' `) | (cd app/dist/js ; tar -xf -)

I suppose that you want to copy all the '*.html' files from app/ts to app/js directory keeping the directory structure and there are no spaces in the file names.

There are some more methods. find and cpio combination usually appears in the manual page of find like here:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download