예제 #1
0
파일: gulp.py 프로젝트: wufeishow/sublime
    def fetch_json(self):
        cache_file = CacheFile(self.working_dir)
        gulpfile = self.get_gulpfile_path(self.working_dir)
        data = None

        if cache_file.exists():
            filesha1 = Hasher.sha1(gulpfile)
            data = cache_file.read()

            if gulpfile in data and data[gulpfile]["sha1"] == filesha1:
                return data[gulpfile]["tasks"]

        self.callcount += 1

        if self.callcount == 1:
            return self.write_to_cache()

        if data is None:
            raise Exception("Could not write to cache gulpfile.")

        if gulpfile in data:
            raise Exception(
                "Sha1 from gulp cache ({0}) is not equal to calculated ({1}).\nTry erasing the cache and running Gulp again."
                .format(data[gulpfile]["sha1"], filesha1))
        else:
            raise Exception(
                "Have you renamed a folder?.\nSometimes Sublime doesn't update the project path, try removing the folder from the project and adding it again."
            )
예제 #2
0
 def delete_cache(self, file_index):
     if file_index > -1:
         self.working_dir = self.gulp_files[file_index]
         try:
             cache_file = CacheFile(self.working_dir)
             if cache_file.exists():
                 cache_file.remove()
                 self.status_message('Cache removed successfully')
         except Exception as e:
             self.status_message("Could not remove cache: %s" % str(e))
예제 #3
0
파일: gulp.py 프로젝트: wufeishow/sublime
 def delete_cache(self, file_index):
     if file_index > -1:
         self.working_dir = self.gulp_files[file_index]
         try:
             cache_file = CacheFile(self.working_dir)
             if cache_file.exists():
                 cache_file.remove()
                 self.status_message('Cache removed successfully')
         except Exception as e:
             self.status_message("Could not remove cache: %s" % str(e))
예제 #4
0
파일: gulp.py 프로젝트: wufeishow/sublime
    def write_to_cache_without_js(self):
        process = CrossPlatformProcess(self.working_dir)
        (stdout, stderr) = process.run_sync(r'gulp -v')

        if process.failed or not GulpVersion(stdout).supports_tasks_simple():
            raise Exception(
                "Gulp: Could not get the current gulp version or your gulp CLI version is lower than 3.7.0"
            )

        (stdout, stderr) = process.run_sync(r'gulp --tasks-simple')

        gulpfile = self.get_gulpfile_path(self.working_dir)

        if not stdout:
            raise Exception(
                "Gulp: The result of `gulp --tasks-simple` was empty")

        CacheFile(self.working_dir).write({
            gulpfile: {
                "sha1":
                Hasher.sha1(gulpfile),
                "tasks":
                dict((task, {
                    "name": task,
                    "dependencies": ""
                }) for task in stdout.split("\n") if task)
            }
        })
예제 #5
0
    def fetch_json(self):
        cache_file = CacheFile(self.working_dir)
        gulpfile = self.get_gulpfile_path(self.working_dir)
        data = None

        if cache_file.exists():
            filesha1 = Hasher.sha1(gulpfile)
            data = cache_file.read()

            if gulpfile in data and data[gulpfile]["sha1"] == filesha1:
                return data[gulpfile]["tasks"]

        self.callcount += 1

        if self.callcount == 1:
            return self.write_to_cache()

        if data is None:
            raise Exception("Could not write to cache gulpfile.")

        if gulpfile in data:
            raise Exception("Sha1 from gulp cache ({0}) is not equal to calculated ({1}).\nTry erasing the cache and running Gulp again.".format(data[gulpfile]["sha1"], filesha1))
        else:
            raise Exception("Have you renamed a folder?.\nSometimes Sublime doesn't update the project path, try removing the folder from the project and adding it again.")