@@ -50,6 +50,8 @@ exports.IsopackCache = function (options) {
5050
5151 self . _noLineNumbers = ! ! options . noLineNumbers ;
5252
53+ self . _lintLocalPackages = ! ! options . lintLocalPackages ;
54+
5355 self . allLoadedLocalPackagesWatchSet = new watch . WatchSet ;
5456} ;
5557
@@ -226,6 +228,8 @@ _.extend(exports.IsopackCache.prototype, {
226228 var isopack ;
227229 if ( previousIsopack && self . _checkUpToDatePreloaded ( previousIsopack ) ) {
228230 isopack = previousIsopack ;
231+ // We don't need to call self._lintLocalPackage here, because
232+ // lintingMessages is saved on the isopack.
229233 } else {
230234 var pluginCacheDir ;
231235 if ( self . _pluginCacheDirRoot ) {
@@ -241,8 +245,7 @@ _.extend(exports.IsopackCache.prototype, {
241245 // Reuse existing plugin cache dir
242246 pluginCacheDir && files . mkdir_p ( pluginCacheDir ) ;
243247
244- var Isopack = isopackModule . Isopack ;
245- isopack = new Isopack ( ) ;
248+ isopack = new isopackModule . Isopack ( ) ;
246249 isopack . initFromPath ( name , self . _isopackDir ( name ) , {
247250 isopackBuildInfoJson : isopackBuildInfoJson ,
248251 pluginCacheDir : pluginCacheDir
@@ -255,6 +258,10 @@ _.extend(exports.IsopackCache.prototype, {
255258 isopack . setPluginProviderPackageMap (
256259 self . _packageMap . makeSubsetMap (
257260 _ . keys ( isopackBuildInfoJson . pluginProviderPackageMap ) ) ) ;
261+ // Because we don't save linter messages to disk, we have to relint
262+ // this package.
263+ // XXX save linter messages to disk?
264+ self . _lintLocalPackage ( packageInfo . packageSource , isopack ) ;
258265 } else {
259266 // Nope! Compile it again. Give it a fresh plugin cache.
260267 if ( pluginCacheDir ) {
@@ -272,37 +279,45 @@ _.extend(exports.IsopackCache.prototype, {
272279 // Accept the compiler's result, even if there were errors (since it
273280 // at least will have a useful WatchSet and will allow us to keep
274281 // going and compile other packages that depend on this one). However,
275- // only save it to disk if there were no errors.
276- if ( self . cacheDir && ! buildmessage . jobHasMessages ( ) ) {
277- // Save to disk, for next time!
278- isopack . saveToPath ( self . _isopackDir ( name ) , {
279- includeIsopackBuildInfo : true
280- } ) ;
282+ // only lint it and save it to disk if there were no errors.
283+ if ( ! buildmessage . jobHasMessages ( ) ) {
284+ // Lint the package. We do this before saving so that the linter can
285+ // augment the saved-to-disk WatchSet with linter-specific files.
286+ self . _lintLocalPackage ( packageInfo . packageSource , isopack ) ;
287+ if ( self . cacheDir ) {
288+ // Save to disk, for next time!
289+ isopack . saveToPath ( self . _isopackDir ( name ) , {
290+ includeIsopackBuildInfo : true
291+ } ) ;
292+ }
281293 }
282294 }
283295 }
284296
285297 self . allLoadedLocalPackagesWatchSet . merge ( isopack . getMergedWatchSet ( ) ) ;
286298 self . _isopacks [ name ] = isopack ;
299+ } ) ;
300+ } ,
287301
288- // lint isopack if compilation succeeded or if we loaded it from cache
289- if ( ! buildmessage . jobHasMessages ( ) ) {
290- var lintingMessages = buildmessage . capture ( {
291- title : "linting isopack " + name
292- } , function ( ) {
293- compiler . lint ( packageInfo . packageSource , {
294- isopackCache : self ,
295- isopack : isopack ,
296- includeCordovaUnibuild : self . _includeCordovaUnibuild
297- } ) ;
298- } ) ;
299- if ( ! lintingMessages . hasMessages ( ) ) {
300- lintingMessages = null ;
301- }
302+ // Runs appropriate linters on a package. It also augments their unibuilds'
303+ // WatchSets with files used by the linter.
304+ _lintLocalPackage ( packageSource , isopack ) {
305+ const self = this ;
306+ if ( ! self . _lintLocalPackages )
307+ return ;
302308
303- isopack . lintingMessages = lintingMessages ;
304- }
309+ const lintingMessages = buildmessage . capture ( {
310+ title : "linting isopack " + isopack . name
311+ } , function ( ) {
312+ compiler . lint ( packageSource , {
313+ isopackCache : self ,
314+ isopack : isopack ,
315+ includeCordovaUnibuild : self . _includeCordovaUnibuild
316+ } ) ;
305317 } ) ;
318+ if ( lintingMessages . hasMessages ( ) ) {
319+ isopack . lintingMessages = lintingMessages ;
320+ }
306321 } ,
307322
308323 _checkUpToDate : function ( isopackBuildInfoJson ) {
@@ -405,7 +420,6 @@ _.extend(exports.IsopackCache.prototype, {
405420
406421 var messages = new buildmessage . _MessageSet ( ) ;
407422 self . _packageMap . eachPackage ( function ( name , packageInfo ) {
408- var packageInfo = self . _packageMap . getInfo ( name ) ;
409423 var isopack = self . _isopacks [ name ] ;
410424 if ( packageInfo . kind === 'local' ) {
411425 var isopackMessages = isopack . lintingMessages ;
0 commit comments