Coder Social home page Coder Social logo

danielkucal / symlink-resolver Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 2.0 15 KB

Simple tool for replacing symlinks by real files and vice versa. Created for #nativescript builds.

License: MIT License

JavaScript 3.42% TypeScript 96.58%
symlink symlinks symlink-alternative nativescript build-tool

symlink-resolver's Introduction

Symlink Resolver

This tool allows to replace symbolic links by real files in given directory and revert the changes back to symlinks. All the magic in a simple cli command!

Installation

npm install symlink-resolver --save-dev

Node.js v6.4+ and POSIX-standarized operating system are required.

To your package.json scripts section add the following rule:

"scripts": {
    "symlink-resolver": "symlink-resolver",
}

Basic Usage

For fast usage you can simply run:

  • npm run symlink-resolver build ./symlinks/path to replace symlinks by real files in ./symlinks/path
  • npm run symlink-resolver clear ./symlinks/path to restore all symlinks

First command will create ./symlinks/path/.symlinks.json file which contains changes that have been made in this directory. It will be removed by the second command, however you can still add to your .gitignore the following rule: .symlinks.json

How to create a symlink?

Use ln -s target source command, i.e.:

ln -s ../../source/path/linked-dir ./project/src/linked-dir

Advanced usage

If you need this feature to make a build, then I strongly recommend to automatize your building process:

"scripts": {
        "symlink-resolver": "symlink-resolver",
        "prebuild": "npm run symlink-resolver build ./symlinks/path",
        "postbuild": "npm run symlink-resolver clear ./symlinks/path",
        "build": "your build command should be under this name"
}

This way you will be able to make a build and edit your files without worries.

However, in some cases like emulating a device, the "post" script will not be executed. If this is also your case then take a look at example workaround for NativeScript:

  "scripts": {
    "symlink-resolver": "symlink-resolver",
    "prens-bundle": "npm run symlink-resolver build ./symlinks/path",
    "delay-clear": "sleep 22 && npm run symlink-resolver clear ./symlinks/path",
    "ns-bundle": "npm run delay-clear | ns-bundle",
    "start-android-bundle": "npm run ns-bundle --android --start-app",
    "start-ios-bundle": "npm run ns-bundle --ios --start-app",
    "build-android-bundle": "npm run ns-bundle --android --build-app",
    "build-ios-bundle": "npm run ns-bundle --ios --build-app"
  },

Advanced configuration

You can adjust Config to your needs.

  • Want to use custom symlinks file name? No problem, just set Config.symlinksFile to whatever you want.
  • Need some custom behavior? Simply extend SymlinkHelper class and set Config.helperClass to yours.
export interface ConfigInterface {
    rootDir: string;
    symlinksFile: string;
    helperClass: typeof SymlinkHelper;
}
Happy developing!

symlink-resolver's People

Contributors

danielkucal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.