@@ -355,6 +355,7 @@ public abstract class Frontend implements Jooby.Module {
355355 public Frontend (String nodeVersion ) {
356356 this .nodeVersion = requireNonNull (nodeVersion , "Node version required." );
357357 }
358+
358359 /**
359360 * Set working directory (location of package.json).
360361 *
@@ -447,25 +448,13 @@ private void onSyncPackageJson(Config conf, Path workDirectory, Throwing.Consume
447448 throws IOException {
448449 Path tmp = Paths .get (conf .getString ("application.tmpdir" ), "frontend" );
449450 Files .createDirectories (tmp );
450-
451- Throwing .Consumer <String > syncPackageJson = existingSha1 -> {
452- Path packageJson = workDirectory .resolve ("package.json" );
453- String sha1 = Hashing .sha1 ().hashBytes (Files .readAllBytes (packageJson )).toString ();
454- if (!existingSha1 .equals (sha1 )) {
455- action .accept ("install" );
456- Files .write (tmp .resolve ("package.json." + sha1 ), Arrays .asList ("" ));
457- }
458- };
459-
460- if (!Files .exists (workDirectory .resolve ("node_modules" ))) {
461- syncPackageJson .accept ("" );
462- } else {
463- String existingSha1 = Files
464- .find (tmp , 1 , (path , attr ) -> path .getFileName ().toString ().startsWith ("package.json." ))
465- .findFirst ()
466- .map (path -> path .getFileName ().toString ().replace ("package.json." , "" ))
467- .orElse ("" );
468- syncPackageJson .accept (existingSha1 );
451+ String sha1 = Hashing .sha1 ()
452+ .hashBytes (Files .readAllBytes (workDirectory .resolve ("package.json" )))
453+ .toString ();
454+ Path lastSha1 = tmp .resolve (sha1 + ".package.json" );
455+ if (!Files .exists (lastSha1 ) || !Files .exists (workDirectory .resolve ("node_modules" ))) {
456+ action .accept ("install" );
457+ Files .write (tmp .resolve (lastSha1 ), Arrays .asList ("" ));
469458 }
470459 }
471460
0 commit comments