Skip to content

Instantly share code, notes, and snippets.

@davenotik
Last active January 25, 2016 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davenotik/d8e0914146d9d33f4046 to your computer and use it in GitHub Desktop.
Save davenotik/d8e0914146d9d33f4046 to your computer and use it in GitHub Desktop.
/// Deploy the (client-side) app safely.
///
/// This builds changes to a new directory, then swaps directory
/// names so that we continue serving with near-zero downtime.
///
/// See https://goo.gl/rdHHrP.
import 'dart:io';
main() async {
print('Running `pub build`...');
await Process.run('pub', ['build']);
print('Swapping directories...');
new Directory('deploy/web').createSync(recursive: true);
var deployDir = new Directory('deploy/web');
var buildDir = new Directory('build/web');
var oldDir = deployDir.renameSync('deploy/web_old');
buildDir.renameSync('deploy/web');
oldDir.deleteSync(recursive: true);
print('''
And we\'re live!
(Don\'t forget to restart the server if anything changed there.)
''');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment