New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

tscopy

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tscopy

Copy a typescript project from somewhere to otherwhere. Just like `cp` but patch import syntaxes.

latest
Source
npmnpm
Version
0.0.8
Version published
Maintainers
1
Created
Source

tscopy

Copy a typescript project from somewhere to otherwhere. Just like cp but patch import syntaxes.

复制一个 typescript 工程到另一个文件夹。就像 cp 命令一样,不过会自动处理其中的 import 语法。

Install

npm i -g tscopy

Usage

  • in CLI

tscopy source target [--ignore=]

tscopy ./zph/myproject ./zph/hisproject/src/submodule/myproject [--ignore=node_modules,package.json]

We will mkdir ./zph/hisproject/src/submodule/myproject then put files on ./zph/myproject

  • ignore: string. Split with ,, ignore some files, defaults to node_modules.
  • in Node
import tscopy from 'tscopy';

tscopy({
  source: './zph/myproject',
  target: './zph/hisproject/src/submodule/myproject',
  ignore: [ 'node_modules', /package\.json/ ]
});
  • ignore: string | (string | RegExp)[].

Description

The tsconfig.json in ./myproject:

{
  "compilerOptions": {
    "baseUrl": "../zph",
    "paths": {
      "react": "hisproject/node_modules/react",
      "helper": "hisproject/src/utils/helper",
      "myproject/*": "myproject/*",
    }
  }
}

tscopy ./zph/myproject ./zph/hisproject/src/submodule/myproject

Before in ./zph/myproject/src/index.tsx:

import React from 'react'
import helper from 'helper'
import CommonTable from 'myproject/src/component/CommonTable'

After in ./zph/hisproject/src/submodule/myproject/src/index.tsx:

import React from 'react'
import helper from '../../utils/helper'
import CommonTable from './component/CommonTable'

Tips

  • We always prefer relative path after transform.
  • We don't transform the packages imported in 'node_modules'.

Keywords

typescript

FAQs

Package last updated on 17 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts