New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mako-tree

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mako-tree - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

5

HISTORY.md
1.5.0 / 2016-11-09
==================
* feat(file): add copy method (#34)
1.4.0 / 2016-11-02

@@ -3,0 +8,0 @@ ==================

@@ -193,2 +193,20 @@ 'use strict'

/**
* Performs a deep copy of this file, making the following alterations after
* successfully cloning:
* - a new id is generated (so it can be added to a tree as a different file)
* - uses `newPath` to update the path (relative to the current path)
*
* @param {String} newPath The relative path for this new file.
* @return {File} copy
*/
copy (newPath) {
assert(newPath, 'a new path is required to copy a file')
debug('copying %s', utils.relative(this.path))
let copy = this.clone()
copy.path = path.resolve(this.dirname, newPath)
copy.id = uuid.v4()
return copy
}
/**
* Returns a trimmed object that can be serialized as JSON. It strips the tree

@@ -195,0 +213,0 @@ * link and includes all other properties, including the custom ones.

2

package.json
{
"name": "mako-tree",
"version": "1.4.0",
"version": "1.5.0",
"main": "./lib/tree",

@@ -5,0 +5,0 @@ "description": "The build tree structure used internally by mako",

@@ -226,2 +226,11 @@ # mako-tree

### File#clone()
Creates a clone of this file, such as when cloning the parent `Tree`.
### File#copy(newPath)
Copies this file to a `newPath` (relative to current path) with a new ID that
can be added to a `Tree` as a distinct file.
### File#toJSON()

@@ -228,0 +237,0 @@

@@ -339,2 +339,37 @@ /* eslint-env mocha */

describe('#copy(newPath)', function () {
it('should return a new File instance', function () {
let serverJS = new File('/path/to/server.js')
assert.instanceOf(serverJS.copy('./client.js'), File)
})
it('should make a deep clone', function () {
let tree = new Tree()
let serverJS = new File('/path/to/server.js', tree)
serverJS.custom = 'value'
let clientJS = serverJS.copy('./client.js')
assert.strictEqual(clientJS.tree, tree)
assert.strictEqual(clientJS.cwd, process.cwd())
assert.strictEqual(clientJS.custom, 'value')
})
it('should set the new path relative to the current path', function () {
let tree = new Tree()
let serverJS = new File('/path/to/server.js', tree)
let clientJS = serverJS.copy('./client.js')
assert.strictEqual(clientJS.path, '/path/to/client.js')
assert.deepEqual(clientJS.history, [ '/path/to/server.js', '/path/to/client.js' ])
})
it('should generate a new id', function () {
let tree = new Tree()
let serverJS = new File('/path/to/server.js', tree)
let clientJS = serverJS.copy('./client.js')
assert.notStrictEqual(serverJS.id, clientJS.id)
})
})
describe('#toJSON()', function () {

@@ -341,0 +376,0 @@ it('should return a cloned object', function () {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc