@@ -5,8 +5,9 @@ import blueprints from '../lib/blueprints';
55import Ember from 'ember' ;
66import moment from 'moment' ;
77import _template from "lodash/template" ;
8+ import { pushDeletion } from 'ember-twiddle/utils/push-deletion' ;
89
9- const { computed, inject, RSVP , $, testing } = Ember ;
10+ const { computed, inject, RSVP , run , $, testing } = Ember ;
1011const twiddleAppName = 'twiddle' ;
1112const oldTwiddleAppNames = [ 'demo-app' , 'app' ] ;
1213const hbsPlugin = new HbsPlugin ( Babel ) ;
@@ -162,7 +163,9 @@ export default Ember.Service.extend({
162163 } ,
163164
164165 generate ( type ) {
165- return this . get ( 'store' ) . createRecord ( 'gistFile' , this . buildProperties ( type ) ) ;
166+ let store = this . get ( 'store' ) ;
167+ run ( ( ) => pushDeletion ( store , 'gist-file' , type ) ) ;
168+ return store . createRecord ( 'gistFile' , this . buildProperties ( type ) ) ;
166169 } ,
167170
168171 buildProperties ( type , replacements ) {
@@ -331,27 +334,27 @@ export default Ember.Service.extend({
331334 url: 'https://cdnjs.cloudflare.com/ajax/libs/qunit/2.3.2/qunit.js',
332335 dataType: 'text'
333336 }).then(function(script) {
334- var oldQUnit;
335- if (window.QUnit) {
336- oldQUnit = window.QUnit;
337- }
338- window.QUnit = {
339- config: {
340- autostart: false
341- }
342- }
343- eval(script);
344- if (!oldQUnit) {
345- oldQUnit = window.QUnit;
346- }
347- if (window.testModule) {
348- window.require(window.testModule);
349- }
350- window.QUnit.start = function() {};
351- window.QUnit.done(function() {
352- window.QUnit = oldQUnit;
353- });
354337 Ember.run(function() {
338+ var oldQUnit;
339+ if (window.QUnit) {
340+ oldQUnit = window.QUnit;
341+ }
342+ window.QUnit = {
343+ config: {
344+ autostart: false
345+ }
346+ }
347+ eval(script);
348+ if (!oldQUnit) {
349+ oldQUnit = window.QUnit;
350+ }
351+ if (window.testModule) {
352+ window.require(window.testModule);
353+ }
354+ window.QUnit.start = function() {};
355+ window.QUnit.done(function() {
356+ window.QUnit = oldQUnit;
357+ });
355358 oldQUnit.start();
356359 });
357360 });
@@ -400,9 +403,11 @@ export default Ember.Service.extend({
400403
401404 checkRequiredFiles ( out , gist ) {
402405 requiredFiles . forEach ( filePath => {
403- var file = gist . get ( 'files' ) . findBy ( 'filePath' , filePath ) ;
404- if ( ! file ) {
405- gist . get ( 'files' ) . pushObject ( this . get ( 'store' ) . createRecord ( 'gistFile' , {
406+ let file = gist . get ( 'files' ) . findBy ( 'filePath' , filePath ) ;
407+ if ( ! file ) {
408+ let store = this . get ( 'store' ) ;
409+ run ( ( ) => pushDeletion ( store , 'gist-file' , filePath ) ) ;
410+ gist . get ( 'files' ) . pushObject ( store . createRecord ( 'gistFile' , {
406411 filePath : filePath ,
407412 content : blueprints [ filePath ]
408413 } ) ) ;
0 commit comments