use glob.sync to prevent race condition