Comparing version 0.4.1 to 0.5.0
0.5.0 / 2015-12-01 | ||
================== | ||
* adding ability to mark a file as dirty externally | ||
0.4.1 / 2015-10-29 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -11,6 +11,7 @@ | ||
debug('initialize %s', location); | ||
this.type = extension(location); | ||
this.path = location; | ||
this.entry = !!entry; | ||
this.tree = tree; | ||
this.analyzing = false; | ||
this.dirty(); | ||
} | ||
@@ -42,2 +43,11 @@ | ||
dirty() { | ||
if (this.analyzing) { | ||
throw new Error('this file is currently being analyzed'); | ||
} | ||
this.type = extension(this.path); | ||
this.analyzed = false; | ||
} | ||
clone(tree) { | ||
@@ -44,0 +54,0 @@ let file = new File(this.location); |
{ | ||
"name": "mako-tree", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "The build tree structure used internally by mako", | ||
@@ -5,0 +5,0 @@ "repository": "makojs/tree", |
@@ -6,2 +6,4 @@ # mako-tree | ||
[![npm version](https://img.shields.io/npm/v/mako-tree.svg)](https://www.npmjs.com/package/mako-tree) | ||
[![npm dependencies](https://img.shields.io/david/makojs/tree.svg)](https://david-dm.org/makojs/tree) | ||
[![npm dev dependencies](https://img.shields.io/david/dev/makojs/tree.svg)](https://david-dm.org/makojs/tree#info=devDependencies) | ||
[![build status](https://img.shields.io/travis/makojs/tree.svg)](https://travis-ci.org/makojs/tree) | ||
@@ -170,10 +172,5 @@ | ||
A flag that helps mako know when a particular file has already been analyzed, so it doesn't | ||
continuously analyze the same file during subsequent builds. | ||
continuously analyze the same file during subsequent builds. Do not change this manually, | ||
instead use `File#dirty()`. | ||
In a `prewrite` hook, setting this property to `false` is effectively marking this file as "dirty", | ||
causing mako to run all the analyze hooks again. | ||
For example, [mako-stat](http://github.com/makojs/stat) will turn this flag off whenever the | ||
modification time for a file has changed. | ||
### File#isEntry() | ||
@@ -202,1 +199,13 @@ | ||
Short-hand for `tree.dependantsOf(file.path, recursive)`. | ||
### File#dirty() | ||
Can be used by the `prewrite` hook to mark a file as "dirty" so that it should be analyzed again. | ||
For example, [mako-stat](http://github.com/makojs/stat) will use this method whenever the | ||
modification time for a file has changed, which indicates to mako that analyze needs to be run | ||
again for this file. | ||
### File#clone(tree) | ||
Returns a new `File` object that is an effective clone of the original. |
@@ -120,2 +120,24 @@ | ||
describe('#dirty()', function () { | ||
it('should turn off the analyzed flag', function () { | ||
let file = new File('index.jade'); | ||
file.analyzed = true; | ||
file.dirty(); | ||
assert.isFalse(file.analyzed); | ||
}); | ||
it('should reset the file type', function () { | ||
let file = new File('index.jade'); | ||
file.type = 'html'; // mock transpilation | ||
file.dirty(); | ||
assert.strictEqual(file.type, 'jade'); | ||
}); | ||
it('should throw when the analyzing flag is turned on', function () { | ||
let file = new File('index.jade'); | ||
file.analyzing = true; | ||
assert.throws(() => file.dirty()); | ||
}); | ||
}); | ||
describe('#clone(tree)', function () { | ||
@@ -122,0 +144,0 @@ it('should create a new copy of the file', function () { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33539
662
209