Example #1
0
    }).finally(() => {
      hexo.config.post_asset_folder = false;

      return Promise.all([
        fs.unlink(file.source),
        fs.unlink(assetPath)
      ]);
    });
Example #2
0
File: new.js Project: GUTIREZ/hexo
    })).then(() => fs.exists(path)).then(exist => {
      exist.should.be.true;

      return Promise.all([
        fs.unlink(path),
        fs.unlink(pathFn.join(hexo.source_dir, '_posts', 'Hello-World.md'))
      ]);
    });
Example #3
0
      generate()).then(() => fs.readFile(dest)).then(result => {
      result.should.eql(content);

      // Remove source files and generated files
      return Promise.all([
        fs.unlink(src),
        fs.unlink(dest)
      ]);
    });
Example #4
0
    }).then(function(result) {
      result.should.eql(content);

      // Remove source files and generated files
      return Promise.all([
        fs.unlink(src),
        fs.unlink(dest)
      ]);
    });
Example #5
0
    }).then(function(stats) {
      stats.mtime.getTime().should.be.above(mtime);

      // Remove source files and generated files
      return Promise.all([
        fs.unlink(src),
        fs.unlink(dest)
      ]);
    });
Example #6
0
      generate({force: true})).then(() => fs.stat(dest)).then(stats => {
      stats.mtime.getTime().should.be.above(mtime);

      // Remove source files and generated files
      return Promise.all([
        fs.unlink(src),
        fs.unlink(dest)
      ]);
    });
Example #7
0
    }).then(function() {
      var post = Post.findOne({source: file.path});
      should.not.exist(PostAsset.findById(assetId));

      return Promise.all([
        post.remove(),
        fs.unlink(file.source),
        fs.unlink(assetPath)
      ]);
    });
Example #8
0
      fs.readFile(dest)).then(result => {
      // Make sure the generated file didn't changed
      result.should.eql(newContent);

      // Remove source files and generated files
      return Promise.all([
        fs.unlink(src),
        fs.unlink(dest)
      ]);
    });
Example #9
0
    return fs.writeFile(packagePath, JSON.stringify(pkg)).then(() => updatePkg(hexo)).then(() => fs.readFile(packagePath)).then(content => {
      // Don't change the original package.json
      JSON.parse(content).should.eql(pkg);
      hexo.env.init.should.be.false;

      return fs.unlink(packagePath);
    });
Example #10
0
    }).then(function() {
      hexo._dbLoaded.should.be.true;
      hexo.model('Test').toArray({lean: true}).should.eql(fixture.models.Test);
      hexo.model('Test').destroy();

      return fs.unlink(dbPath);
    });
Example #11
0
  it('database load success', () => fs.writeFile(dbPath, JSON.stringify(fixture)).then(() => loadDatabase(hexo)).then(() => {
    hexo._dbLoaded.should.be.true;
    hexo.model('Test').toArray({lean: true}).should.eql(fixture.models.Test);
    hexo.model('Test').destroy();

    return fs.unlink(dbPath);
  }));
Example #12
0
File: post.js Project: 08opt/hexo
 }).then(function(post) {
   return Promise.all([
     fs.exists(assetDir),
     fs.listDir(newAssetDir),
     fs.unlink(post.path)
   ]);
 }).spread(function(exist, files) {
Example #13
0
  return fs.exists(dbPath).then(function(exist){
    if (!exist) return;

    return fs.unlink(dbPath).then(function(){
      ctx.log.info('Deleted database.');
    });
  });
Example #14
0
    }).then(function(){
      hexo.config.foo.should.eql(1);

      reset();
      hexo.config_path = pathFn.join(hexo.base_dir, '_config.yml');
      return fs.unlink(configPath);
    });
Example #15
0
    }).then(function(){
      hexo.config.root.should.eql('foo/');
      hexo.config.url.should.eql('http://hexo.io');

      reset();
      return fs.unlink(hexo.config_path);
    });
Example #16
0
    }).then(function() {
      hexo.config.post_asset_folder = false;

      var post = Post.findOne({source: file.path});
      var asset = PostAsset.findById(assetId);

      asset._id.should.eql(assetId);
      asset.post.should.eql(post._id);
      asset.modified.should.be.true;

      return Promise.all([
        post.remove(),
        fs.unlink(file.source),
        fs.unlink(assetPath)
      ]);
    });
Example #17
0
    }).then(function(data) {
      data[0].path.should.eql('test.min.js');

      return Promise.all([
        Asset.removeById(path),
        fs.unlink(source)
      ]);
    });
Example #18
0
    }).finally(() => {
      hexo.config.post_asset_folder = false;

      return Promise.all([
        Post.removeById(postId),
        fs.unlink(file.source)
      ]);
    });
Example #19
0
    return fs.writeFile(configPath, '{}').then(() => config({_: ['title', 'My Blog']})).then(() => fs.readFile(configPath)).then(content => {
      const json = JSON.parse(content);

      json.title.should.eql('My Blog');

      hexo.config_path = pathFn.join(hexo.base_dir, '_config.yml');
      return fs.unlink(configPath);
    });
Example #20
0
    }).then(function(){
      hexo.config.theme.should.eql('test');
      hexo.theme_dir.should.eql(pathFn.join(hexo.base_dir, 'themes', 'test') + pathFn.sep);
      hexo.theme_script_dir.should.eql(pathFn.join(hexo.theme_dir, 'scripts') + pathFn.sep);
      hexo.theme.base.should.eql(hexo.theme_dir);

      reset();
      return fs.unlink(hexo.config_path);
    });
Example #21
0
    }).then(function() {
      var post = Post.findOne({source: file.path});
      post.slug.should.eql('foooo');

      return Promise.all([
        post.remove(),
        fs.unlink(file.source)
      ]);
    });
Example #22
0
  function deleteFile(path){
    var dest = join(publicDir, path);

    return fs.unlink(dest).then(function(){
      log.info('Deleted: %s', chalk.magenta(path));
    }, function(err){
      // Skip ENOENT errors (file was deleted)
      if (err.cause.code !== 'ENOENT') throw err;
    });
  }
Example #23
0
File: post.js Project: 08opt/hexo
 }).then(function(data) {
   data.content.should.eql([
     // js-yaml use single-quotation for dumping since 3.3
     'title: \'Foo: Bar\'',
     'date: ' + moment(now).format('YYYY-MM-DD HH:mm:ss'),
     'tags:',
     '---'
   ].join('\n') + '\n');
   return fs.unlink(data.path);
 });
Example #24
0
    }).then(function() {
      var post = Post.findOne({source: file.path});

      post.published.should.be.false;

      return Promise.all([
        post.remove(),
        fs.unlink(file.source)
      ]);
    });
Example #25
0
File: asset.js Project: hexojs/hexo
    return fs.writeFile(file.source, body).then(() => process(file)).then(() => {
      const page = Page.findOne({source: file.path});

      page.path.should.eql('test.min.js');

      return Promise.all([
        page.remove(),
        fs.unlink(file.source)
      ]);
    });
Example #26
0
    }).then(function() {
      var post = Post.findOne({source: file.path});

      post.date.format(dateFormat).should.eql('2014-04-24 00:00:00');
      post.updated.format(dateFormat).should.eql('2015-05-05 00:00:00');

      return Promise.all([
        post.remove(),
        fs.unlink(file.source)
      ]);
    });
Example #27
0
    }).spread(function(stats) {
      var post = Post.findOne({source: file.path});

      post.date.toDate().should.eql(stats.ctime);
      post.updated.toDate().should.eql(stats.mtime);

      return Promise.all([
        post.remove(),
        fs.unlink(file.source)
      ]);
    });
Example #28
0
File: asset.js Project: hexojs/hexo
    return fs.writeFile(file.source, body).then(() => process(file)).then(() => {
      const page = Page.findOne({source: file.path});

      page.date.utc().format(dateFormat).should.eql('2014-04-24 00:00:00');
      page.updated.utc().format(dateFormat).should.eql('2015-05-05 00:00:00');

      return Promise.all([
        page.remove(),
        fs.unlink(file.source)
      ]);
    }).finally(() => {
Example #29
0
File: asset.js Project: hexojs/hexo
    ])).spread(stats => {
      const page = Page.findOne({source: file.path});

      page.date.toDate().should.eql(stats.ctime);
      page.updated.toDate().should.eql(stats.mtime);

      return Promise.all([
        page.remove(),
        fs.unlink(file.source)
      ]);
    });
Example #30
0
File: asset.js Project: hexojs/hexo
    }).then(() => {
      const page = Page.findOne({source: file.path});

      page._id.should.eql(id);
      page.title.should.eql('Hello world');

      return Promise.all([
        page.remove(),
        fs.unlink(file.source)
      ]);
    });