Beispiel #1
0
    def write_to_cache_without_js(self):
        process = CrossPlatformProcess(self)
        (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")

        self.write_cache_file({
            gulpfile: {
                "sha1":
                Hasher.sha1(gulpfile),
                "tasks":
                dict((task, {
                    "name": task,
                    "dependencies": ""
                }) for task in stdout.split("\n") if task)
            }
        })
Beispiel #2
0
    def fetch_json(self):
        jsonfilename = os.path.join(self.working_dir, GulpCommand.cache_file_name)
        gulpfile = self.get_gulpfile_path(self.working_dir)
        data = None

        if os.path.exists(jsonfilename):
            filesha1 = Hasher.sha1(gulpfile)
            json_data = codecs.open(jsonfilename, "r", "utf-8", errors='replace')

            try:
                data = json.load(json_data)
                if gulpfile in data and data[gulpfile]["sha1"] == filesha1:
                    return data[gulpfile]["tasks"]
            finally:
                json_data.close()

        self.callcount += 1

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

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

        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))
Beispiel #3
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."
            )
Beispiel #4
0
    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)
            }
        })
Beispiel #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.")