Skip to content

Instantly share code, notes, and snippets.

@sillero
Last active July 8, 2018 02:49
Show Gist options
  • Select an option

  • Save sillero/0293ac86e3f6224b7ff1c079b1fa2a67 to your computer and use it in GitHub Desktop.

Select an option

Save sillero/0293ac86e3f6224b7ff1c079b1fa2a67 to your computer and use it in GitHub Desktop.

Revisions

  1. Gus Sillero renamed this gist Jul 8, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Gus Sillero revised this gist Jul 8, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion extend-json
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,4 @@
    TARGET=$(tr -d '\n' < $1)
    SOURCE=$(tr -d '\n' < $2)

    node -e "console.log(JSON.stringify(Object.assign($TARGET, $SOURCE), false, 4))"
    node -e "console.log(JSON.stringify({ ...$TARGET, ...$SOURCE }, false, 4))"
  3. Gus Sillero created this gist Jul 8, 2018.
    8 changes: 8 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    Requires nodejs

    Usage:
    ```
    # extend-json <target-path> <source-path>
    extend-json a/package.json b/package.json > a/package.json
    ```
    5 changes: 5 additions & 0 deletions extend-json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    #!/bin/bash
    TARGET=$(tr -d '\n' < $1)
    SOURCE=$(tr -d '\n' < $2)

    node -e "console.log(JSON.stringify(Object.assign($TARGET, $SOURCE), false, 4))"