Fix plan merging and running
1 files changed, 15 insertions(+), 11 deletions(-)

M lib/assemblage/assembly_builder.rb
M lib/assemblage/assembly_builder.rb +15 -11
@@ 254,31 254,35 @@ class Assemblage::AssemblyBuilder
 		scripts = SCRIPT_PATH.each_with_object( {} ) do |pathspec, hash|
 			self.log.debug "  looking for assembly scripts in %s" % [ pathspec ]
 			base = pathspec % vars
-			self.log.debug "  expanded to: %s" % [ base ]
 			pattern = Pathname( base ) + '*'
+			self.log.debug "  expanded to: %s" % [ pattern ]
+
 			Pathname.glob( pattern ).each do |file|
 				hash[ file.basename ] = file
 			end
 		end
 
-		self.plan.merge( scripts )
+		self.plan.replace( scripts )
 		self.log.debug "Plan is: %p" % [ self.plan ]
 	end
 
 
 	### Builder stage: Execute the assembly scripts in the #plan.
 	def execute_assembly_scripts
-		self.plan.keys.sort.each do |basename|
-			script = self.plan[ basename ]
+		Dir.chdir( self.work_dir ) do
+			self.log.debug "Working directory is: %s" % [ Dir.pwd ]
+			self.plan.keys.sort.each do |basename|
+				script = self.plan[ basename ]
 
-			unless script.executable?
-				self.add_build_log "  skipping: not executable."
-				next
+				unless script.executable?
+					self.add_build_log "  skipping: not executable."
+					next
+				end
+
+				self.add_build_log "Executing %s" % [ script ]
+				cmd = TTY::Command.new
+				cmd.run( script )
 			end
-
-			self.add_build_log "Executing %s" % [ script ]
-			cmd = TTY::Command.new
-			cmd.run( script )
 		end
 	end